19 lines
		
	
	
		
			457 B
		
	
	
	
		
			Plaintext
		
	
	
	
	
	
			
		
		
	
	
			19 lines
		
	
	
		
			457 B
		
	
	
	
		
			Plaintext
		
	
	
	
	
	
|   u64 allocation_size = sizeof({ArrayType}) + sizeof({T}) * capacity;
 | |
|   {ArrayType} *array     = NULL;
 | |
| 
 | |
|   if (!allocator) {{
 | |
|     goto RETURN_{Tupper}_ARRAY_ALLOC;
 | |
|   }}
 | |
| 
 | |
|   array = wapp_mem_allocator_alloc(allocator, allocation_size);
 | |
|   if (!array) {{
 | |
|     goto RETURN_{Tupper}_ARRAY_ALLOC;
 | |
|   }}
 | |
| 
 | |
|   array->items    = ({T} *)((u8 *)array + sizeof({ArrayType}));
 | |
|   array->count    = 0;
 | |
|   array->capacity = capacity;
 | |
| 
 | |
| RETURN_{Tupper}_ARRAY_ALLOC:
 | |
|   return array;
 |