Add static, runtime and debug assert utilities
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
assert(allocator != NULL);
|
||||
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);
|
||||
|
@@ -1,4 +1,4 @@
|
||||
assert(allocator != NULL && array != NULL);
|
||||
wapp_debug_assert(allocator != NULL && array != NULL, "`allocator` and `array` should not be NULL");
|
||||
|
||||
{ArrayType} *output = array;
|
||||
|
||||
|
@@ -1,4 +1,5 @@
|
||||
assert(array != NULL && array->count < array->capacity);
|
||||
wapp_debug_assert(array != NULL, "`array` should not be NULL");
|
||||
wapp_runtime_assert(array->count < array->capacity, "`array` is full");
|
||||
|
||||
u64 index = (array->count)++;
|
||||
wapp_{Tlower}_array_set(array, index, item);
|
||||
|
@@ -1,4 +1,5 @@
|
||||
assert(array != NULL && index < array->count);
|
||||
wapp_debug_assert(array != NULL, "`array` should not be NULL");
|
||||
wapp_runtime_assert(index < array->count, "`index` is out of bounds");
|
||||
|
||||
u8 *ptr = (u8 *)(array->items) + (array->item_size * index);
|
||||
return ({T} *)ptr;
|
||||
|
@@ -1,2 +1,2 @@
|
||||
assert(array != NULL);
|
||||
wapp_debug_assert(array != NULL, "`array` should not be NULL");
|
||||
array->count = 0;
|
||||
|
@@ -1,4 +1,4 @@
|
||||
assert(allocator != NULL && src != NULL && dst != NULL);
|
||||
wapp_debug_assert(allocator != NULL && src != NULL && dst != NULL, "`allocator`, `src` and `dst` should not be NULL");
|
||||
|
||||
{ArrayType} *output = dst;
|
||||
|
||||
|
@@ -1,4 +1,4 @@
|
||||
assert(src != NULL && dst != NULL);
|
||||
wapp_debug_assert(src != NULL && dst != NULL, "`src` and `dst` should not be NULL");
|
||||
|
||||
wapp_{Tlower}_array_clear(dst);
|
||||
|
||||
|
@@ -1,4 +1,4 @@
|
||||
assert(allocator != NULL && array != NULL && other != NULL);
|
||||
wapp_debug_assert(allocator != NULL && array != NULL && other != NULL, "`allocator`, `array` and `other` should not be NULL");
|
||||
|
||||
{ArrayType} *output = array;
|
||||
|
||||
|
@@ -1,7 +1,7 @@
|
||||
assert(array != NULL && other != NULL);
|
||||
wapp_debug_assert(array != NULL && other != NULL, "`array` and `other` should not be NULL");
|
||||
|
||||
u64 remaining_capacity = array->capacity - array->count;
|
||||
assert(other->count < remaining_capacity);
|
||||
wapp_runtime_assert(other->count < remaining_capacity, "`array` does not have enough capacity");
|
||||
|
||||
{T} *item;
|
||||
|
||||
|
Reference in New Issue
Block a user