X-Git-Url: https://git.lttng.org/?p=lttng-tools.git;a=blobdiff_plain;f=src%2Fbin%2Flttng-sessiond%2Ftrace-kernel.c;h=54bdc667575ec48a0b2d5ac3fadcc999148150ae;hp=083add3f30f907eee80dc259b0e961f028e50ab3;hb=df3c77c8dbbd102718f7149b075ba026d70a9e27;hpb=55d7bb027104ac0afd80be872e0ff7ebb832216e diff --git a/src/bin/lttng-sessiond/trace-kernel.c b/src/bin/lttng-sessiond/trace-kernel.c index 083add3f3..54bdc6675 100644 --- a/src/bin/lttng-sessiond/trace-kernel.c +++ b/src/bin/lttng-sessiond/trace-kernel.c @@ -257,11 +257,33 @@ struct ltt_kernel_context *trace_kernel_create_context( if (ctx) { memcpy(&kctx->ctx, ctx, sizeof(kctx->ctx)); } +error: + return kctx; +} - CDS_INIT_LIST_HEAD(&kctx->list); +/* + * Allocate and init a kernel context object from an existing kernel context + * object. + * + * Return the allocated object or NULL on error. + */ +struct ltt_kernel_context *trace_kernel_copy_context( + struct ltt_kernel_context *kctx) +{ + struct ltt_kernel_context *kctx_copy; + + assert(kctx); + kctx_copy = zmalloc(sizeof(*kctx_copy)); + if (!kctx_copy) { + PERROR("zmalloc ltt_kernel_context"); + goto error; + } + + memcpy(kctx_copy, kctx, sizeof(*kctx_copy)); + memset(&kctx_copy->list, 0, sizeof(kctx_copy->list)); error: - return kctx; + return kctx_copy; } /*