# HG changeset patch # User Matti Hamalainen # Date 1670407134 -7200 # Node ID 2ae1045f6c18d316467a61addcdd2a2a6b8caa22 # Parent 79d06eb6d39f22855df1ee4f10ca8dc83e9d2091 Improve documentation. diff -r 79d06eb6d39f -r 2ae1045f6c18 th_datastruct.h --- 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);