Add a util to create a buffer view from a raw buffer
authorJérémie Galarneau <jeremie.galarneau@efficios.com>
Tue, 17 Oct 2017 21:18:14 +0000 (17:18 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Fri, 24 Aug 2018 19:27:54 +0000 (15:27 -0400)
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
src/common/buffer-view.c
src/common/buffer-view.h

index 4e84b0335eccee4b3a6c786f6014b07a1be4dd01..6053501efa7ae59fa9b309793499d3269147ee93 100644 (file)
 #include <common/error.h>
 #include <assert.h>
 
+LTTNG_HIDDEN
+struct lttng_buffer_view lttng_buffer_view_init(
+               const char *src, size_t offset, ptrdiff_t len)
+{
+       struct lttng_buffer_view view = { .data = src + offset, .size = len };
+       return view;
+}
+
 LTTNG_HIDDEN
 struct lttng_buffer_view lttng_buffer_view_from_view(
                const struct lttng_buffer_view *src, size_t offset,
index d2b18f663a0d8596889d2346aba33df11dc2d024..878b845bc77412bb801f81207a1bd38b5a0fd13e 100644 (file)
@@ -29,6 +29,21 @@ struct lttng_buffer_view {
        size_t size;
 };
 
+/**
+ * Return a buffer view referencing a subset of the memory referenced by a raw
+ * pointer.
+ *
+ * @src                Source buffer to reference
+ * @offset     Offset to apply to the source memory buffer
+ * @len                Length of the memory contents to reference.
+ *
+ * Note that a buffer view never assumes the ownership of the memory it
+ * references.
+ */
+LTTNG_HIDDEN
+struct lttng_buffer_view lttng_buffer_view_init(
+               const char *src, size_t offset, ptrdiff_t len);
+
 /**
  * Return a buffer view referencing a subset of the memory referenced by another
  * view.
This page took 0.033501 seconds and 4 git commands to generate.