summaryrefslogtreecommitdiff
path: root/arr.c
diff options
context:
space:
mode:
authorLeo Tenenbaum <pommicket@gmail.com>2019-09-29 20:36:14 -0400
committerLeo Tenenbaum <pommicket@gmail.com>2019-09-29 20:36:14 -0400
commitc8e6972ee18a95db544980513f619567a3bc171e (patch)
tree8f5882e9371d2d400958ecf03651792611c5f3ff /arr.c
parented62db5344e1fb39f17883c69bd398d18758f29b (diff)
finished replacing err_malloc with allocators; now there are no memory leaks!
Diffstat (limited to 'arr.c')
-rw-r--r--arr.c6
1 files changed, 1 insertions, 5 deletions
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) {