Add lttng_dynamic_buffer_append_view util
[lttng-tools.git] / src / common / dynamic-buffer.c
index 1ae2fa2c52fade3662c3f05de648f77323f24d51..b6544e62ba5f3f646bd9bd1630a9ca5668b5f190 100644 (file)
@@ -6,6 +6,7 @@
  */
 
 #include <common/dynamic-buffer.h>
+#include <common/buffer-view.h>
 #include <common/utils.h>
 #include <assert.h>
 
@@ -68,7 +69,7 @@ end:
 
 LTTNG_HIDDEN
 int lttng_dynamic_buffer_append_buffer(struct lttng_dynamic_buffer *dst_buffer,
-               struct lttng_dynamic_buffer *src_buffer)
+               const struct lttng_dynamic_buffer *src_buffer)
 {
        int ret;
 
@@ -83,6 +84,23 @@ end:
        return ret;
 }
 
+LTTNG_HIDDEN
+int lttng_dynamic_buffer_append_view(struct lttng_dynamic_buffer *buffer,
+               const struct lttng_buffer_view *src)
+{
+       int ret;
+
+       if (!buffer || !src) {
+               ret = -1;
+               goto end;
+       }
+
+       ret = lttng_dynamic_buffer_append(buffer, src->data,
+                       src->size);
+end:
+       return ret;
+}
+
 LTTNG_HIDDEN
 int lttng_dynamic_buffer_set_size(struct lttng_dynamic_buffer *buffer,
                size_t new_size)
This page took 0.023381 seconds and 4 git commands to generate.