|
|
|
@ -75,7 +75,8 @@ void * arlst_del(ArrayList *l, int id) {
@@ -75,7 +75,8 @@ void * arlst_del(ArrayList *l, int id) {
|
|
|
|
|
size_t new_size = l-> size + (l->capacity * (100 / D_SHRINK_THRESHOLD) *
|
|
|
|
|
100 / D_GROW_AMOUNT); |
|
|
|
|
|
|
|
|
|
l->items = reallocarray(l->items, new_size, sizeof(void *)); |
|
|
|
|
// l->items = reallocarray(l->items, new_size, sizeof(void *));
|
|
|
|
|
l->items = realloc(l->items, new_size * sizeof(void *)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return item; |
|
|
|
@ -88,7 +89,8 @@ int arlst_add(ArrayList *l, void *item) {
@@ -88,7 +89,8 @@ int arlst_add(ArrayList *l, void *item) {
|
|
|
|
|
if (l->size == l->capacity) { |
|
|
|
|
size_t new_size = l->capacity + (100 / D_GROW_AMOUNT) * l->capacity; |
|
|
|
|
l->capacity = new_size; |
|
|
|
|
l->items = (void **)reallocarray(l->items, new_size, sizeof(void *)); |
|
|
|
|
//l->items = (void **)reallocarray(l->items, new_size, sizeof(void *));
|
|
|
|
|
l->items = (void **)realloc(l->items, new_size * sizeof(void *)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
l->items[item_index] = item; |
|
|
|
|