diff options
-rw-r--r-- | src/driver/sfrt_driver_ctx.c | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/src/driver/sfrt_driver_ctx.c b/src/driver/sfrt_driver_ctx.c index 58ea3ce..7a9f81c 100644 --- a/src/driver/sfrt_driver_ctx.c +++ b/src/driver/sfrt_driver_ctx.c @@ -51,7 +51,10 @@ static int sfrt_driver_usage( return SFRT_USAGE; } -static struct sfrt_driver_ctx_impl * sfrt_driver_ctx_alloc(struct argv_meta * meta, size_t nunits) +static struct sfrt_driver_ctx_impl * sfrt_driver_ctx_alloc( + struct argv_meta * meta, + const struct sfrt_common_ctx * cctx, + size_t nunits) { struct sfrt_driver_ctx_alloc * ictx; size_t size; @@ -64,6 +67,9 @@ static struct sfrt_driver_ctx_impl * sfrt_driver_ctx_alloc(struct argv_meta * me if (!(ictx = calloc(size,1))) return 0; + if (cctx) + memcpy(&ictx->ctx.cctx,cctx,sizeof(*cctx)); + for (entry=meta->entries,units=ictx->units; entry->fopt || entry->arg; entry++) if (!entry->fopt) *units++ = entry->arg; @@ -131,13 +137,12 @@ int sfrt_get_driver_ctx( nunits++; } - if (!(ctx = sfrt_driver_ctx_alloc(meta,nunits))) + if (!(ctx = sfrt_driver_ctx_alloc(meta,&cctx,nunits))) return sfrt_get_driver_ctx_fail(meta); ctx->ctx.program = program; ctx->ctx.cctx = &ctx->cctx; - memcpy(&ctx->cctx,&cctx,sizeof(cctx)); *pctx = &ctx->ctx; return SFRT_OK; } @@ -153,7 +158,7 @@ int sfrt_create_driver_ctx( if (!(meta = argv_get(argv,sfrt_default_options,0))) return -1; - if (!(ctx = sfrt_driver_ctx_alloc(meta,0))) + if (!(ctx = sfrt_driver_ctx_alloc(meta,cctx,0))) return sfrt_get_driver_ctx_fail(0); ctx->ctx.cctx = &ctx->cctx; |