common: move copy_filter_bytecode to bytecode.c and rename it
[lttng-tools.git] / src / common / bytecode / bytecode.c
index b8edd6913e18fa9fe1b4f7dbb753380c05a59e89..e85dd66c14eb90a6584c882d9401bd70ccba0822 100644 (file)
@@ -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;
+}
This page took 0.022699 seconds and 4 git commands to generate.