diff options
Diffstat (limited to 'src/badlib.h')
-rw-r--r-- | src/badlib.h | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/src/badlib.h b/src/badlib.h index a91fcf8..71f4bee 100644 --- a/src/badlib.h +++ b/src/badlib.h | |||
@@ -11,6 +11,7 @@ | |||
11 | // - Implement binary search for searching into an array: | 11 | // - Implement binary search for searching into an array: |
12 | // SearchResult find_array(Array haystack, Array needle). | 12 | // SearchResult find_array(Array haystack, Array needle). |
13 | // - Logger functions for hash map and queues. | 13 | // - Logger functions for hash map and queues. |
14 | // - Make assert/abort macros dump the file name/line? | ||
14 | // | 15 | // |
15 | 16 | ||
16 | #include <stdarg.h> | 17 | #include <stdarg.h> |
@@ -811,6 +812,9 @@ _array_reserve(sz num_elem, sz type_size, Arena *a) { | |||
811 | 812 | ||
812 | static inline void * | 813 | static inline void * |
813 | _array_maybe_grow(void *arr, sz type_size, Arena *a) { | 814 | _array_maybe_grow(void *arr, sz type_size, Arena *a) { |
815 | if (!arr) { | ||
816 | arr = _array_reserve(0, 0, a); | ||
817 | } | ||
814 | ArrayHeader *head = array_head(arr); | 818 | ArrayHeader *head = array_head(arr); |
815 | if (head->cap == head->size) { | 819 | if (head->cap == head->size) { |
816 | sz prev_size = head->cap * type_size + sizeof(ArrayHeader); | 820 | sz prev_size = head->cap * type_size + sizeof(ArrayHeader); |