20 lines
485 B
Plaintext
20 lines
485 B
Plaintext
u64 allocation_size = sizeof({ArrayType}) + item_size * capacity;
|
|
{ArrayType} *array = NULL;
|
|
|
|
if (!allocator) {{
|
|
goto RETURN_GENERIC_ARRAY_ALLOC;
|
|
}}
|
|
|
|
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;
|