X-Git-Url: http://git.lttng.org/?p=lttng-tools.git;a=blobdiff_plain;f=src%2Fbin%2Flttng-sessiond%2Futils.c;h=febf2305826a5ce31c7033e111457aae5040618c;hp=f84859fc621645aea1939d7c04648c7ac729682a;hb=44760c20f4fc255b63894ca758cf2ee5f253220b;hpb=ce0b1d61919f37517a6212f7af2afe0fa1b1dcb0 diff --git a/src/bin/lttng-sessiond/utils.c b/src/bin/lttng-sessiond/utils.c index f84859fc6..febf23058 100644 --- a/src/bin/lttng-sessiond/utils.c +++ b/src/bin/lttng-sessiond/utils.c @@ -98,3 +98,26 @@ const char *consumer_output_get_base_path(const struct consumer_output *output) output->dst.session_root_path : output->dst.net.base_dir; } + +/* + * Allocate a filter and copy the given original filter. + * + * Return allocated filter or NULL on error. + */ +struct lttng_filter_bytecode *lttng_filter_bytecode_copy( + const struct lttng_filter_bytecode *orig_f) +{ + struct lttng_filter_bytecode *filter = NULL; + + /* Copy filter bytecode */ + filter = zmalloc(sizeof(*filter) + orig_f->len); + if (!filter) { + PERROR("zmalloc alloc filter bytecode"); + goto error; + } + + memcpy(filter, orig_f, sizeof(*filter) + orig_f->len); + +error: + return filter; +}