aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--arraylist.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/arraylist.c b/arraylist.c
index f72d3e2..bb4d0c2 100644
--- a/arraylist.c
+++ b/arraylist.c
@@ -17,7 +17,7 @@ struct ArrayList {
17}; 17};
18 18
19static T ** 19static T **
20ArrayList_allocate(void *ptr, size_t nelem) 20ArrayList_allocateArray(void *ptr, size_t nelem)
21{ 21{
22 T **new_ptr = reallocarray(ptr, nelem, sizeof *new_ptr); 22 T **new_ptr = reallocarray(ptr, nelem, sizeof *new_ptr);
23 23
@@ -79,11 +79,11 @@ ArrayList_growIfNeeded(struct ArrayList *arrayList)
79 static const size_t DEFAULT_CAPACITY = 10; 79 static const size_t DEFAULT_CAPACITY = 10;
80 80
81 arrayList->capacity = DEFAULT_CAPACITY; 81 arrayList->capacity = DEFAULT_CAPACITY;
82 arrayList->array = ArrayList_allocate(NULL, DEFAULT_CAPACITY); 82 arrayList->array = ArrayList_allocateArray(NULL, DEFAULT_CAPACITY);
83 } 83 }
84 else { 84 else {
85 size_t new_capacity = (arrayList->capacity * 3) / 2; // *= 1.5 85 size_t new_capacity = (arrayList->capacity * 3) / 2; // *= 1.5
86 T ** new_arrayList = ArrayList_allocate(arrayList->array, new_capacity); 86 T ** new_arrayList = ArrayList_allocateArray(arrayList->array, new_capacity);
87 87
88 arrayList->capacity = new_capacity; 88 arrayList->capacity = new_capacity;
89 arrayList->array = new_arrayList; 89 arrayList->array = new_arrayList;