SoW-2019-0002: Dynamic Snapshot
[lttng-tools.git] / src / bin / lttng-sessiond / utils.c
index f84859fc621645aea1939d7c04648c7ac729682a..2ae586b512a7117c4ed5d761c84a93283ad679c2 100644 (file)
@@ -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 *copy_filter_bytecode(
+               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;
+}
This page took 0.024813 seconds and 5 git commands to generate.