#include "../includes/array.h" #include #define ARRAY_DEFAULT_CAPACITY 32 struct _array* ArrayCreate(void) { struct _array* array = calloc(1, sizeof(Array)); array->Items = calloc(ARRAY_DEFAULT_CAPACITY, sizeof(void*)); array->Capacity = ARRAY_DEFAULT_CAPACITY; return array; } int ArrayAdd(struct _array* array, void* item) { if (!array) return 0; if (array->Size == array->Capacity) { array->Items = realloc(array->Items, array->Capacity * 2 * sizeof(void*)); array->Capacity *= 2; } array->Items[array->Size] = item; array->Size++; return 1; }