16 lines
433 B
Plaintext
16 lines
433 B
Plaintext
assert(allocator != NULL);
|
|
|
|
u64 allocation_size = sizeof({ArrayType}) + item_size * capacity;
|
|
{ArrayType} *array = wapp_mem_allocator_alloc(allocator, allocation_size);
|
|
if (!array) {{
|
|
goto RETURN_GENERIC_ARRAY_ALLOC;
|
|
}}
|
|
|
|
array->items = ({T} *)((u8 *)array + sizeof({ArrayType}));
|
|
array->count = 0;
|
|
array->capacity = capacity;
|
|
array->item_size = item_size;
|
|
|
|
RETURN_GENERIC_ARRAY_ALLOC:
|
|
return array;
|