diff th_datastruct.h @ 736:ca837a4417f5

Add simple growing pointerlist data stucture implementation.
author Matti Hamalainen <ccr@tnsp.org>
date Wed, 07 Dec 2022 15:03:09 +0200
parents 31bc1ed07cf5
children 3091fd1987e9
line wrap: on
line diff
--- a/th_datastruct.h	Wed Dec 07 12:14:39 2022 +0200
+++ b/th_datastruct.h	Wed Dec 07 15:03:09 2022 +0200
@@ -116,6 +116,23 @@
 bool    th_growbuf_put_u32_le(th_growbuf_t *buf, const uint32_t val);
 
 
+/** @brief
+ * Growing pointerlist/array structure
+ */
+typedef struct
+{
+    bool is_allocated;
+    size_t nitems, nallocated, ngrow;
+    void **items;
+} th_ptrlist_t;
+
+
+int     th_ptrlist_init(th_ptrlist_t *list, const size_t ninitial, const size_t ngrow);
+int     th_ptrlist_new(th_ptrlist_t **list, const size_t ninitial, const size_t ngrow);
+int     th_ptrlist_append(th_ptrlist_t *list, void *str);
+void    th_ptrlist_free(th_ptrlist_t *list, void (*mdeallocator)(void *data));
+
+
 #ifdef __cplusplus
 }
 #endif