65 #define DARRAY_DEFAULT_CAPACITY 1
68 #define DARRAY_RESIZE_FACTOR 2
76 #define darray_create(type) \
77 _darray_create(DARRAY_DEFAULT_CAPACITY, sizeof(type), 0)
86 #define darray_create_with_allocator(type, allocator) \
87 _darray_create(DARRAY_DEFAULT_CAPACITY, sizeof(type), allocator)
96 #define darray_reserve(type, capacity) \
97 _darray_create(capacity, sizeof(type), 0)
107 #define darray_reserve_with_allocator(type, capacity, allocator) \
108 _darray_create(capacity, sizeof(type), allocator)
122 #define darray_push(array, value) \
124 typeof(value) temp = value; \
125 array = _darray_push(array, &temp); \
146 #define darray_insert_at(array, index, value) \
148 typeof(value) temp = value; \
149 array = _darray_insert_at(array, index, &temp); \
KAPI void darray_length_set(void *array, u64 value)
Sets the length of the given array. This ensures the array has the required capacity to be able to se...
KAPI u64 darray_capacity(void *array)
Gets the given array's capacity.
KAPI void * _darray_insert_at(void *array, u64 index, void *value_ptr)
Inserts a copy of the given value into the supplied array at the given index. Triggers an array resiz...
KAPI void darray_destroy(void *array)
Destroys the provided array, freeing any memory allocated by it.
KAPI void * _darray_resize(void *array)
Resizes the given array using internal resizing amounts. Causes a new allocation.
KAPI u64 darray_stride(void *array)
Gets the stride (element size) of the given array.
KAPI void darray_clear(void *array)
Clears all entries from the array. Does not release any internally-allocated memory.
KAPI void darray_pop(void *array, void *value_ptr)
Pops an entry out of the array and places it into dest.
KAPI void * darray_pop_at(void *array, u64 index, void *value_ptr)
Pops an entry out of the array at the given index and places it into dest. Brings in all entries afte...
KAPI void * _darray_create(u64 length, u64 stride, struct frame_allocator_int *frame_allocator)
Creates a new darray of the given length and stride. Note that this performs a dynamic memory allocat...
KAPI u64 darray_length(void *array)
Gets the length (number of elements) in the given array.
KAPI void * _darray_push(void *array, const void *value_ptr)
Pushes a new entry to the given array. Resizes if necessary.
This file contains global type definitions which are used throughout the entire engine and applicatio...
#define KAPI
Import/export qualifier.
Definition: defines.h:177
unsigned long long u64
Unsigned 64-bit integer.
Definition: defines.h:28
Definition: frame_data.h:7