From c8e6972ee18a95db544980513f619567a3bc171e Mon Sep 17 00:00:00 2001 From: Leo Tenenbaum Date: Sun, 29 Sep 2019 20:36:14 -0400 Subject: finished replacing err_malloc with allocators; now there are no memory leaks! --- arr.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) (limited to 'arr.c') diff --git a/arr.c b/arr.c index fa337e8..ff94377 100644 --- a/arr.c +++ b/arr.c @@ -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) { -- cgit v1.2.3