16 lines
		
	
	
		
			474 B
		
	
	
	
		
			Plaintext
		
	
	
	
	
	
			
		
		
	
	
			16 lines
		
	
	
		
			474 B
		
	
	
	
		
			Plaintext
		
	
	
	
	
	
|   wapp_debug_assert(allocator != NULL, "`array` should not be 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;
 |