diff --git a/stb_ds.h b/stb_ds.h index edd43a7..f1fbd26 100644 --- a/stb_ds.h +++ b/stb_ds.h @@ -380,6 +380,7 @@ CREDITS github:hashitaku github:srdjanstipic Macoy Madson + Andreas Vennstrom */ #ifdef STBDS_UNIT_TESTS @@ -490,6 +491,7 @@ extern void stbds_unit_tests(void); // extern void * stbds_arrgrowf(void *a, size_t elemsize, size_t addlen, size_t min_cap); +extern void stbds_arrfreef(void *a); extern void stbds_hmfree_func(void *p, size_t elemsize); extern void * stbds_hmget_key(void *a, size_t elemsize, void *key, size_t keysize, int mode); extern void * stbds_hmget_key_ts(void *a, size_t elemsize, void *key, size_t keysize, ptrdiff_t *temp, int mode); @@ -544,7 +546,7 @@ extern void * stbds_shmode_func(size_t elemsize, int mode); #define stbds_arraddnptr(a,n) (stbds_arrmaybegrow(a,n), stbds_header(a)->length += (n), &(a)[stbds_header(a)->length-(n)]) #define stbds_arraddnoff(a,n) (stbds_arrmaybegrow(a,n), stbds_header(a)->length += (n), stbds_header(a)->length-(n)) #define stbds_arrlast(a) ((a)[stbds_header(a)->length-1]) -#define stbds_arrfree(a) ((void) ((a) ? STBDS_FREE(NULL,stbds_header(a)) : (void)0), (a)=NULL) +#define stbds_arrfree(a) ((void) ((a) ? stbds_arrfreef(a) : (void)0), (a)=NULL) #define stbds_arrdel(a,i) stbds_arrdeln(a,i,1) #define stbds_arrdeln(a,i,n) (memmove(&(a)[i], &(a)[(i)+(n)], sizeof *(a) * (stbds_header(a)->length-(n)-(i))), stbds_header(a)->length -= (n)) #define stbds_arrdelswap(a,i) ((a)[i] = stbds_arrlast(a), stbds_header(a)->length -= 1) @@ -793,6 +795,11 @@ void *stbds_arrgrowf(void *a, size_t elemsize, size_t addlen, size_t min_cap) return b; } +void stbds_arrfreef(void *a) +{ + STBDS_FREE(NULL, stbds_header(a)); +} + // // stbds_hm hash table implementation //