#include "allocator.h" #include struct da_template { int count; int capacity; void *items; struct Mem *mem; }; // the array struct has to be freed manually, all internal data is freedd by // dyn_array_destroy void *dyn_array_create() { struct da_template *da = malloc(sizeof(struct da_template)); da->items = malloc(0); da->capacity = 0; da->count = 0; da->mem = NULL; return da; } // the array struct has to be freed manually, all internal data is freedd by // dyn_array_destroy void *dyn_array_create_mem(struct Mem *mem) { struct da_template *da = mem_malloc(mem, sizeof(struct da_template)); da->items = mem_malloc(mem, 0); da->capacity = 0; da->count = 0; da->mem = mem; return da; } void dyn_array_create_inplace(void *array) { struct da_template *da = array; da->items = malloc(0); da->count = 0; da->capacity = 0; da->mem = NULL; } void dyn_array_create_inplace_mem(void *array, struct Mem *mem) { struct da_template *da = array; da->items = mem_malloc(mem, 0); da->count = 0; da->capacity = 0; da->mem = mem; }