Add lttng_dynamic_buffer_get_capacity_left util
authorJérémie Galarneau <jeremie.galarneau@efficios.com>
Tue, 17 Oct 2017 21:21:10 +0000 (17:21 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Fri, 24 Aug 2018 18:39:02 +0000 (14:39 -0400)
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
src/common/dynamic-buffer.c
src/common/dynamic-buffer.h

index fd39f813b3c2568beec2dff1be91343161ec8517..2e27afa1f92f446c12de25a0f268f6de33623536 100644 (file)
@@ -186,3 +186,13 @@ void lttng_dynamic_buffer_reset(struct lttng_dynamic_buffer *buffer)
        buffer->_capacity = 0;
        free(buffer->data);
 }
+
+LTTNG_HIDDEN
+size_t lttng_dynamic_buffer_get_capacity_left(
+               struct lttng_dynamic_buffer *buffer)
+{
+       if (!buffer) {
+               return 0;
+       }
+       return buffer->_capacity - buffer->size;
+}
index d42a6a61df8401ba62732d3a79a8b8f3ea44b875..cd23ccad4d4d45fcdc59254328180daf39b51586 100644 (file)
@@ -94,4 +94,9 @@ int lttng_dynamic_buffer_set_capacity(struct lttng_dynamic_buffer *buffer,
 LTTNG_HIDDEN
 void lttng_dynamic_buffer_reset(struct lttng_dynamic_buffer *buffer);
 
+/* Get the space left in the buffer before a new resize is needed. */
+LTTNG_HIDDEN
+size_t lttng_dynamic_buffer_get_capacity_left(
+               struct lttng_dynamic_buffer *buffer);
+
 #endif /* LTTNG_DYNAMIC_BUFFER_H */
This page took 0.025491 seconds and 4 git commands to generate.