Skip to content
Myr

stb_ds: STBDS_REALLOC and STBDS_FREE only need to be defined for the implementation.

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Andy Durdin · committed by Andy Durdin · parent 6b2fb77 · Browse files · 1 file+8 added−2 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+8 added−2 removed

  • other:+8 added−2 removed

1 file+8 added−2 removed

modified:stb_ds.h+8 added-2 removed
42 unmodified lines
4344 #define STBDS_REALLOC better_realloc45 #define STBDS_FREE better_free4647 These defines need to be set globally.47 These defines only need to be set in the file containing #define STB_DS_IMPLEMENTATION.4849 By default stb_ds uses stdlib realloc() and free() for memory management. You can50 substitute your own functions (with the same signatures) instead by defining these51 symbols. You must either define both, or neither.
370 unmodified lines
422extern void * stbds_hmput_default(void *a, size_t elemsize);423extern void * stbds_hmput_key(void *a, size_t elemsize, void *key, size_t keysize, int mode);424extern void * stbds_hmdel_key(void *a, size_t elemsize, void *key, size_t keysize, size_t keyoffset, int mode);425extern void * stbds_shmode_func(size_t elemsize, int mode);426extern void stbds_free(void *p);427428#ifdef __cplusplus429}430#endif
36 unmodified lines
467#define stbds_arrpush stbds_arrput // synonym468#define stbds_arrpop(a) (stbds_header(a)->length--, (a)[stbds_header(a)->length])469#define stbds_arraddn(a,n) (stbds_arrmaybegrow(a,n), stbds_header(a)->length += (n))470#define stbds_arrlast(a) ((a)[stbds_header(a)->length-1])470#define stbds_arrfree(a) ((void) ((a) ? STBDS_FREE(stbds_header(a)) : (void)0), (a)=NULL)471#define stbds_arrfree(a) ((void) ((a) ? stbds_free(stbds_header(a)) : (void)0), (a)=NULL)472#define stbds_arrdel(a,i) stbds_arrdeln(a,i,1)473#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))474#define stbds_arrdelswap(a,i) ((a)[i] = stbds_arrlast(a), stbds_header(a)->length -= 1)475#define stbds_arrinsn(a,i,n) (stbds_arraddn((a),(n)), memmove(&(a)[(i)+(n)], &(a)[i], sizeof *(a) * (stbds_header(a)->length-(n)-(i))))
165 unmodified lines
641#else642#define STBDS_STATS(x)643#endif644645void stbds_free(void *p)646{647 STBDS_FREE(p);648}649650//651// stbds_arr implementation652//653
1039 unmodified lines