comparison 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
comparison
equal deleted inserted replaced
735:31bc1ed07cf5 736:ca837a4417f5
114 bool th_growbuf_put_u16_le(th_growbuf_t *buf, const uint16_t val); 114 bool th_growbuf_put_u16_le(th_growbuf_t *buf, const uint16_t val);
115 bool th_growbuf_put_u32_be(th_growbuf_t *buf, const uint32_t val); 115 bool th_growbuf_put_u32_be(th_growbuf_t *buf, const uint32_t val);
116 bool th_growbuf_put_u32_le(th_growbuf_t *buf, const uint32_t val); 116 bool th_growbuf_put_u32_le(th_growbuf_t *buf, const uint32_t val);
117 117
118 118
119 /** @brief
120 * Growing pointerlist/array structure
121 */
122 typedef struct
123 {
124 bool is_allocated;
125 size_t nitems, nallocated, ngrow;
126 void **items;
127 } th_ptrlist_t;
128
129
130 int th_ptrlist_init(th_ptrlist_t *list, const size_t ninitial, const size_t ngrow);
131 int th_ptrlist_new(th_ptrlist_t **list, const size_t ninitial, const size_t ngrow);
132 int th_ptrlist_append(th_ptrlist_t *list, void *str);
133 void th_ptrlist_free(th_ptrlist_t *list, void (*mdeallocator)(void *data));
134
135
119 #ifdef __cplusplus 136 #ifdef __cplusplus
120 } 137 }
121 #endif 138 #endif
122 #endif // TH_DATASTRUCT_H 139 #endif // TH_DATASTRUCT_H