diff options
author | Preston Pan <ret2pop@gmail.com> | 2024-12-28 16:47:43 -0800 |
---|---|---|
committer | Preston Pan <ret2pop@gmail.com> | 2024-12-28 16:47:43 -0800 |
commit | 1fd608288ee47c2c560817f12f14b21069fed2f6 (patch) | |
tree | e6460b92dba5bb0d089c8c2a4e794e3504098359 /server/array.c | |
parent | 63f11aaec8d21844a07fd27003a992c102a3a297 (diff) |
makefile and directory structure change completely to build client and server
Diffstat (limited to 'server/array.c')
-rw-r--r-- | server/array.c | 37 |
1 files changed, 0 insertions, 37 deletions
diff --git a/server/array.c b/server/array.c deleted file mode 100644 index 84ed938..0000000 --- a/server/array.c +++ /dev/null @@ -1,37 +0,0 @@ -#include <array.h> -#include <helpers.h> -#include <stdlib.h> - -array_t *init_array() { - array_t *a = safe_calloc(1, sizeof(array_t)); - a->capacity = DEFAULT_ARR_LEN; - a->size = 0; - a->items = safe_calloc(a->capacity, sizeof(void *)); - return a; -} - -void array_push(array_t *a, void *item) { - if (a->size >= a->capacity - 2) { - a->capacity *= 2; - a->items = realloc(a->items, a->capacity); - } - a->items[a->size] = item; - a->size++; -} - -void *array_pop(array_t *a) { - if (a->size <= 0) - return NULL; - void *retval = a->items[a->size]; - a->size--; - return retval; -} - -void array_free(void *x, void (*freefunc)(void *)) { - array_t *a = (array_t *)x; - for (int i = 0; i < a->size; i++) { - freefunc(a->items[i]); - } - free(a->items); - free(a); -} |