diff options
author | Leo Tenenbaum <pommicket@gmail.com> | 2019-09-29 20:36:14 -0400 |
---|---|---|
committer | Leo Tenenbaum <pommicket@gmail.com> | 2019-09-29 20:36:14 -0400 |
commit | c8e6972ee18a95db544980513f619567a3bc171e (patch) | |
tree | 8f5882e9371d2d400958ecf03651792611c5f3ff /arr.c | |
parent | ed62db5344e1fb39f17883c69bd398d18758f29b (diff) |
finished replacing err_malloc with allocators; now there are no memory leaks!
Diffstat (limited to 'arr.c')
-rw-r--r-- | arr.c | 6 |
1 files changed, 1 insertions, 5 deletions
@@ -18,7 +18,7 @@ static inline void arr_reserve(Array *arr, size_t n) { static inline void arr_reservea(Array *arr, size_t n, Allocator *a) { arr->cap = n; - arr->data = allocr_realloc(a, arr->data, n); + arr->data = allocr_realloc(a, arr->data, arr->item_sz * arr->cap); } /* like arr_reserve, but sets the length of the array too */ @@ -64,10 +64,6 @@ static void arr_clear(Array *arr) { static void arr_remove_last(Array *arr) { /* OPTIM (memory): Shorten array. */ arr->len--; - if (!arr->len) { - arr_clear(arr); - } - } static void arr_free(Array *arr) { |