diff options
Diffstat (limited to 'arr.c')
-rw-r--r-- | arr.c | 5 |
1 files changed, 5 insertions, 0 deletions
@@ -60,6 +60,10 @@ static inline u32 arr_len(void *arr) { return arr ? arr_hdr_(arr)->len : 0; } +static inline u32 arr_cap(void *arr) { + return arr ? arr_hdr_(arr)->cap : 0; +} + static inline unsigned arr_lenu(void *arr) { return (unsigned)arr_len(arr); } @@ -114,6 +118,7 @@ static void arr_reserve_(void **arr, size_t member_size, size_t n) { if (!*arr) { // create a new array with capacity n+1 + // why n+1? i dont know i wrote this a while ago ArrHeader *hdr = calloc(1, sizeof(ArrHeader) + (n+1) * member_size); if (hdr) { hdr->cap = (u32)n+1; |