changeset 734:2ae1045f6c18

Improve documentation.
author Matti Hamalainen <ccr@tnsp.org>
date Wed, 07 Dec 2022 11:58:54 +0200
parents 79d06eb6d39f
children 31bc1ed07cf5
files th_datastruct.h
diffstat 1 files changed, 15 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/th_datastruct.h	Wed Dec 07 11:57:43 2022 +0200
+++ b/th_datastruct.h	Wed Dec 07 11:58:54 2022 +0200
@@ -55,11 +55,11 @@
  */
 typedef struct
 {
+    BOOL is_allocated; ///< True if this structure has been allocated dynamically
     void **data;    ///< Array of pointers to the data
     size_t size;    ///< Size of this ringbuffer in elements (aka pointers to data)
     size_t n;       ///< Number of elements currently in the ringbuffer (@p n <= @p size)
     void (*deallocator)(void *data); ///< De-allocator function that frees one element.
-    BOOL is_allocated;
 } th_ringbuf_t;
 
 
@@ -75,14 +75,6 @@
 #define TH_BUFGROW       (32)
 
 
-typedef struct
-{
-    BOOL is_allocated;
-    uint8_t *data;
-    size_t size, len, mingrow;
-} th_growbuf_t;
-
-
 /* Simple growing string buffer
  */
 BOOL    th_strbuf_grow(char **buf, size_t *bufsize, size_t *len, const size_t grow);
@@ -91,6 +83,20 @@
 BOOL    th_strbuf_puts(char **buf, size_t *bufsize, size_t *len, const char *str);
 
 
+/** @brief
+ * Simple growing buffer structure
+ */
+typedef struct
+{
+    BOOL is_allocated; ///< True if this structure has been allocated dynamically
+    uint8_t *data;     ///< Pointer to data
+    size_t size;       ///< Current allocated size of data
+    size_t len;        ///< Actual used size of data (must be < size)
+    size_t mingrow;    ///< Minimum amount of bytes to grow allocation by
+                       ///< If 0, grow by TH_BUFGROW
+} th_growbuf_t;
+
+
 /* Growing byte buffer
  */
 void    th_growbuf_init(th_growbuf_t *buf, const size_t mingrow);