X-Git-Url: https://git.lttng.org/?p=lttng-tools.git;a=blobdiff_plain;f=src%2Fcommon%2Fbytecode%2Fbytecode.c;h=e85dd66c14eb90a6584c882d9401bd70ccba0822;hp=b8edd6913e18fa9fe1b4f7dbb753380c05a59e89;hb=763f0d4cef1438d3f1f5f5c5a232d72628bca550;hpb=0ae3cfc61fedae38ef31fe5a99458c4f2161c3b5 diff --git a/src/common/bytecode/bytecode.c b/src/common/bytecode/bytecode.c index b8edd6913..e85dd66c1 100644 --- a/src/common/bytecode/bytecode.c +++ b/src/common/bytecode/bytecode.c @@ -99,3 +99,25 @@ int bytecode_push_logical(struct lttng_filter_bytecode_alloc **fb, - (void *) &(*fb)->b.data[0]; return 0; } + +/* + * Allocate an lttng_bytecode object and copy the given original bytecode. + * + * Return allocated bytecode or NULL on error. + */ +LTTNG_HIDDEN +struct lttng_filter_bytecode *lttng_filter_bytecode_copy( + const struct lttng_filter_bytecode *orig_f) +{ + struct lttng_filter_bytecode *bytecode = NULL; + + bytecode = zmalloc(sizeof(*bytecode) + orig_f->len); + if (!bytecode) { + goto error; + } + + memcpy(bytecode, orig_f, sizeof(*bytecode) + orig_f->len); + +error: + return bytecode; +}