diff --git a/codegen/array/make_array.py b/codegen/array/make_array.py index 8ad7441..af3922c 100644 --- a/codegen/array/make_array.py +++ b/codegen/array/make_array.py @@ -77,11 +77,6 @@ def make_array(user_datatypes: Dict[CDataType, ArrayData] = {}): array_typename="VoidPArray", ) continue - elif _type == CType.BOOL: - datatypes[_type.value] = ArrayData( - array_typename="BoolArray", - ) - continue type_title = _type.value.title() datatypes[_type.value] = ArrayData( diff --git a/codegen/array/snippets/copy_capped b/codegen/array/snippets/copy_capped index cb58bab..0a5e77b 100644 --- a/codegen/array/snippets/copy_capped +++ b/codegen/array/snippets/copy_capped @@ -8,7 +8,7 @@ // MSVC Spectre mitigation warnings u64 to_copy = src->count < dst->capacity ? src->count : dst->capacity; u64 item_index = 0; - bool running = true; + b32 running = true; while (running) {{ item = wapp_{Tlower}_array_get(src, item_index); ++item_index; diff --git a/codegen/array/snippets/extend_capped b/codegen/array/snippets/extend_capped index 7e40dd0..caa77c2 100644 --- a/codegen/array/snippets/extend_capped +++ b/codegen/array/snippets/extend_capped @@ -9,7 +9,7 @@ // MSVC Spectre mitigation warnings u64 items_to_add = other->count; u64 item_index = 0; - bool running = true; + b32 running = true; while (running) {{ item = wapp_{Tlower}_array_get(other, item_index); ++item_index; diff --git a/codegen/datatypes.py b/codegen/datatypes.py index 36cd2df..8d69ce4 100644 --- a/codegen/datatypes.py +++ b/codegen/datatypes.py @@ -9,7 +9,7 @@ from codegen.utils import convert_to_relative class CType(Enum): VOID = "void" - BOOL = "bool" + BOOL = "b32" CHAR = "char" C8 = "c8" C16 = "c16" diff --git a/src/common/aliases/aliases.h b/src/common/aliases/aliases.h index 237f552..6759a0f 100644 --- a/src/common/aliases/aliases.h +++ b/src/common/aliases/aliases.h @@ -28,6 +28,16 @@ #define u32 uint32_t #define u64 uint64_t +#define b32 uint32_t + +#ifndef false +#define false (b32)0 +#endif + +#ifndef true +#define true (b32)1 +#endif + #define i8 int8_t #define i16 int16_t #define i32 int32_t diff --git a/src/primitives/array/array.c b/src/primitives/array/array.c index f05a27e..207e8f1 100644 --- a/src/primitives/array/array.c +++ b/src/primitives/array/array.c @@ -3,16 +3,17 @@ */ #include "./array.h" +#include "../../common/assert/assert.h" +#include "../../common/aliases/aliases.h" #include "../mem_allocator/mem_allocator.h" #include "../../common/misc/misc_utils.h" #include "../../common/aliases/aliases.h" #include "../../common/platform/platform.h" #include -#include -#include Str8 *wapp_str8_array_get(const Str8Array *array, u64 index) { - 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 (Str8 *)ptr; @@ -25,17 +26,18 @@ void wapp_str8_array_set(Str8Array *array, u64 index, Str8 *item) { } void wapp_str8_array_append_capped(Str8Array *array, Str8 *item) { - 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_str8_array_set(array, index, item); } void wapp_str8_array_extend_capped(Str8Array *array, const Str8Array *other) { - 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"); Str8 *item; @@ -43,7 +45,7 @@ void wapp_str8_array_extend_capped(Str8Array *array, const Str8Array *other) { // MSVC Spectre mitigation warnings u64 items_to_add = other->count; u64 item_index = 0; - bool running = true; + b32 running = true; while (running) { item = wapp_str8_array_get(other, item_index); ++item_index; @@ -58,12 +60,12 @@ void wapp_str8_array_extend_capped(Str8Array *array, const Str8Array *other) { } void wapp_str8_array_clear(Str8Array *array) { - assert(array != NULL); + wapp_debug_assert(array != NULL, "`array` should not be NULL"); array->count = 0; } void wapp_str8_array_copy_capped(const Str8Array *src, Str8Array *dst) { - assert(src != NULL && dst != NULL); + wapp_debug_assert(src != NULL && dst != NULL, "`src` and `dst` should not be NULL"); wapp_str8_array_clear(dst); @@ -73,7 +75,7 @@ void wapp_str8_array_copy_capped(const Str8Array *src, Str8Array *dst) { // MSVC Spectre mitigation warnings u64 to_copy = src->count < dst->capacity ? src->count : dst->capacity; u64 item_index = 0; - bool running = true; + b32 running = true; while (running) { item = wapp_str8_array_get(src, item_index); ++item_index; @@ -88,7 +90,7 @@ void wapp_str8_array_copy_capped(const Str8Array *src, Str8Array *dst) { } Str8Array *wapp_str8_array_append_alloc(const Allocator *allocator, Str8Array *array, Str8 *item) { - assert(allocator != NULL && array != NULL); + wapp_debug_assert(allocator != NULL && array != NULL, "`allocator` and `array` should not be NULL"); Str8Array *output = array; @@ -109,7 +111,7 @@ RETURN_STR8_ARRAY_APPEND_ALLOC: } Str8Array *wapp_str8_array_extend_alloc(const Allocator *allocator, Str8Array *array, const Str8Array *other) { - assert(allocator != NULL && array != NULL && other != NULL); + wapp_debug_assert(allocator != NULL && array != NULL && other != NULL, "`allocator`, `array` and `other` should not be NULL"); Str8Array *output = array; @@ -131,7 +133,7 @@ RETURN_STR8_ARRAY_EXTEND_ALLOC: } Str8Array *wapp_str8_array_copy_alloc(const Allocator *allocator, const Str8Array *src, Str8Array *dst) { - assert(allocator != NULL && src != NULL && dst != NULL); + wapp_debug_assert(allocator != NULL && src != NULL && dst != NULL, "`allocator`, `src` and `dst` should not be NULL"); Str8Array *output = dst; @@ -159,7 +161,8 @@ Str8 *_str8_array_pop(Str8Array *array) { } void * *wapp_void_ptr_array_get(const VoidPArray *array, u64 index) { - 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 (void * *)ptr; @@ -172,17 +175,18 @@ void wapp_void_ptr_array_set(VoidPArray *array, u64 index, void * *item) { } void wapp_void_ptr_array_append_capped(VoidPArray *array, void * *item) { - 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_void_ptr_array_set(array, index, item); } void wapp_void_ptr_array_extend_capped(VoidPArray *array, const VoidPArray *other) { - 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"); void * *item; @@ -190,7 +194,7 @@ void wapp_void_ptr_array_extend_capped(VoidPArray *array, const VoidPArray *othe // MSVC Spectre mitigation warnings u64 items_to_add = other->count; u64 item_index = 0; - bool running = true; + b32 running = true; while (running) { item = wapp_void_ptr_array_get(other, item_index); ++item_index; @@ -205,12 +209,12 @@ void wapp_void_ptr_array_extend_capped(VoidPArray *array, const VoidPArray *othe } void wapp_void_ptr_array_clear(VoidPArray *array) { - assert(array != NULL); + wapp_debug_assert(array != NULL, "`array` should not be NULL"); array->count = 0; } void wapp_void_ptr_array_copy_capped(const VoidPArray *src, VoidPArray *dst) { - assert(src != NULL && dst != NULL); + wapp_debug_assert(src != NULL && dst != NULL, "`src` and `dst` should not be NULL"); wapp_void_ptr_array_clear(dst); @@ -220,7 +224,7 @@ void wapp_void_ptr_array_copy_capped(const VoidPArray *src, VoidPArray *dst) { // MSVC Spectre mitigation warnings u64 to_copy = src->count < dst->capacity ? src->count : dst->capacity; u64 item_index = 0; - bool running = true; + b32 running = true; while (running) { item = wapp_void_ptr_array_get(src, item_index); ++item_index; @@ -235,7 +239,7 @@ void wapp_void_ptr_array_copy_capped(const VoidPArray *src, VoidPArray *dst) { } VoidPArray *wapp_void_ptr_array_append_alloc(const Allocator *allocator, VoidPArray *array, void * *item) { - assert(allocator != NULL && array != NULL); + wapp_debug_assert(allocator != NULL && array != NULL, "`allocator` and `array` should not be NULL"); VoidPArray *output = array; @@ -256,7 +260,7 @@ RETURN_VOID_PTR_ARRAY_APPEND_ALLOC: } VoidPArray *wapp_void_ptr_array_extend_alloc(const Allocator *allocator, VoidPArray *array, const VoidPArray *other) { - assert(allocator != NULL && array != NULL && other != NULL); + wapp_debug_assert(allocator != NULL && array != NULL && other != NULL, "`allocator`, `array` and `other` should not be NULL"); VoidPArray *output = array; @@ -278,7 +282,7 @@ RETURN_VOID_PTR_ARRAY_EXTEND_ALLOC: } VoidPArray *wapp_void_ptr_array_copy_alloc(const Allocator *allocator, const VoidPArray *src, VoidPArray *dst) { - assert(allocator != NULL && src != NULL && dst != NULL); + wapp_debug_assert(allocator != NULL && src != NULL && dst != NULL, "`allocator`, `src` and `dst` should not be NULL"); VoidPArray *output = dst; @@ -305,41 +309,43 @@ void * *_void_ptr_array_pop(VoidPArray *array) { return out; } -bool *wapp_bool_array_get(const BoolArray *array, u64 index) { - assert(array != NULL && index < array->count); +b32 *wapp_b32_array_get(const B32Array *array, u64 index) { + 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 (bool *)ptr; + return (b32 *)ptr; } -void wapp_bool_array_set(BoolArray *array, u64 index, bool *item) { - bool *ptr = wapp_bool_array_get(array, index); +void wapp_b32_array_set(B32Array *array, u64 index, b32 *item) { + b32 *ptr = wapp_b32_array_get(array, index); memcpy((void *)ptr, (void *)item, array->item_size); } -void wapp_bool_array_append_capped(BoolArray *array, bool *item) { - assert(array != NULL && array->count < array->capacity); +void wapp_b32_array_append_capped(B32Array *array, b32 *item) { + 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_bool_array_set(array, index, item); + wapp_b32_array_set(array, index, item); } -void wapp_bool_array_extend_capped(BoolArray *array, const BoolArray *other) { - assert(array != NULL && other != NULL); +void wapp_b32_array_extend_capped(B32Array *array, const B32Array *other) { + 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"); - bool *item; + b32 *item; // NOTE (Abdelrahman): Uses a while loop instead of a for loop to get rid of // MSVC Spectre mitigation warnings u64 items_to_add = other->count; u64 item_index = 0; - bool running = true; + b32 running = true; while (running) { - item = wapp_bool_array_get(other, item_index); + item = wapp_b32_array_get(other, item_index); ++item_index; running = item_index < items_to_add; @@ -347,29 +353,29 @@ void wapp_bool_array_extend_capped(BoolArray *array, const BoolArray *other) { continue; } - wapp_bool_array_append_capped(array, item); + wapp_b32_array_append_capped(array, item); } } -void wapp_bool_array_clear(BoolArray *array) { - assert(array != NULL); +void wapp_b32_array_clear(B32Array *array) { + wapp_debug_assert(array != NULL, "`array` should not be NULL"); array->count = 0; } -void wapp_bool_array_copy_capped(const BoolArray *src, BoolArray *dst) { - assert(src != NULL && dst != NULL); +void wapp_b32_array_copy_capped(const B32Array *src, B32Array *dst) { + wapp_debug_assert(src != NULL && dst != NULL, "`src` and `dst` should not be NULL"); - wapp_bool_array_clear(dst); + wapp_b32_array_clear(dst); - bool *item; + b32 *item; // NOTE (Abdelrahman): Uses a while loop instead of a for loop to get rid of // MSVC Spectre mitigation warnings u64 to_copy = src->count < dst->capacity ? src->count : dst->capacity; u64 item_index = 0; - bool running = true; + b32 running = true; while (running) { - item = wapp_bool_array_get(src, item_index); + item = wapp_b32_array_get(src, item_index); ++item_index; running = item_index < to_copy; @@ -377,83 +383,84 @@ void wapp_bool_array_copy_capped(const BoolArray *src, BoolArray *dst) { continue; } - wapp_bool_array_append_capped(dst, item); + wapp_b32_array_append_capped(dst, item); } } -BoolArray *wapp_bool_array_append_alloc(const Allocator *allocator, BoolArray *array, bool *item) { - assert(allocator != NULL && array != NULL); +B32Array *wapp_b32_array_append_alloc(const Allocator *allocator, B32Array *array, b32 *item) { + wapp_debug_assert(allocator != NULL && array != NULL, "`allocator` and `array` should not be NULL"); - BoolArray *output = array; + B32Array *output = array; if (array->count >= array->capacity) { u64 new_capacity = wapp_misc_utils_u64_round_up_pow2(array->capacity * 2); - output = (BoolArray *)_array_alloc_capacity(allocator, new_capacity, array->item_size); + output = (B32Array *)_array_alloc_capacity(allocator, new_capacity, array->item_size); if (!output) { output = array; - goto RETURN_BOOL_ARRAY_APPEND_ALLOC; + goto RETURN_B32_ARRAY_APPEND_ALLOC; } - wapp_bool_array_copy_capped(array, output); + wapp_b32_array_copy_capped(array, output); } - wapp_bool_array_append_capped(output, item); + wapp_b32_array_append_capped(output, item); -RETURN_BOOL_ARRAY_APPEND_ALLOC: +RETURN_B32_ARRAY_APPEND_ALLOC: return output; } -BoolArray *wapp_bool_array_extend_alloc(const Allocator *allocator, BoolArray *array, const BoolArray *other) { - assert(allocator != NULL && array != NULL && other != NULL); +B32Array *wapp_b32_array_extend_alloc(const Allocator *allocator, B32Array *array, const B32Array *other) { + wapp_debug_assert(allocator != NULL && array != NULL && other != NULL, "`allocator`, `array` and `other` should not be NULL"); - BoolArray *output = array; + B32Array *output = array; u64 remaining_capacity = array->capacity - array->count; if (other->count >= remaining_capacity) { u64 new_capacity = wapp_misc_utils_u64_round_up_pow2(array->capacity * 2); - output = (BoolArray *)_array_alloc_capacity(allocator, new_capacity, array->item_size); + output = (B32Array *)_array_alloc_capacity(allocator, new_capacity, array->item_size); if (!output) { output = array; - goto RETURN_BOOL_ARRAY_EXTEND_ALLOC; + goto RETURN_B32_ARRAY_EXTEND_ALLOC; } - wapp_bool_array_copy_capped(array, output); + wapp_b32_array_copy_capped(array, output); } - wapp_bool_array_extend_capped(output, other); + wapp_b32_array_extend_capped(output, other); -RETURN_BOOL_ARRAY_EXTEND_ALLOC: +RETURN_B32_ARRAY_EXTEND_ALLOC: return output; } -BoolArray *wapp_bool_array_copy_alloc(const Allocator *allocator, const BoolArray *src, BoolArray *dst) { - assert(allocator != NULL && src != NULL && dst != NULL); +B32Array *wapp_b32_array_copy_alloc(const Allocator *allocator, const B32Array *src, B32Array *dst) { + wapp_debug_assert(allocator != NULL && src != NULL && dst != NULL, "`allocator`, `src` and `dst` should not be NULL"); - BoolArray *output = dst; + B32Array *output = dst; if (src->count >= dst->capacity) { u64 new_capacity = wapp_misc_utils_u64_round_up_pow2(dst->capacity * 2); - output = (BoolArray *)_array_alloc_capacity(allocator, new_capacity, src->item_size); + output = (B32Array *)_array_alloc_capacity(allocator, new_capacity, src->item_size); if (!output) { output = dst; - goto RETURN_BOOL_ARRAY_COPY_ALLOC; + goto RETURN_B32_ARRAY_COPY_ALLOC; } } - wapp_bool_array_clear(output); - wapp_bool_array_copy_capped(src, output); + wapp_b32_array_clear(output); + wapp_b32_array_copy_capped(src, output); -RETURN_BOOL_ARRAY_COPY_ALLOC: +RETURN_B32_ARRAY_COPY_ALLOC: return output; } -bool *_bool_array_pop(BoolArray *array) { +b32 *_b32_array_pop(B32Array *array) { u64 index = array->count - 1; - bool *out = wapp_bool_array_get(array, index); + b32 *out = wapp_b32_array_get(array, index); --(array->count); return out; } char *wapp_char_array_get(const CharArray *array, u64 index) { - 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 (char *)ptr; @@ -466,17 +473,18 @@ void wapp_char_array_set(CharArray *array, u64 index, char *item) { } void wapp_char_array_append_capped(CharArray *array, char *item) { - 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_char_array_set(array, index, item); } void wapp_char_array_extend_capped(CharArray *array, const CharArray *other) { - 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"); char *item; @@ -484,7 +492,7 @@ void wapp_char_array_extend_capped(CharArray *array, const CharArray *other) { // MSVC Spectre mitigation warnings u64 items_to_add = other->count; u64 item_index = 0; - bool running = true; + b32 running = true; while (running) { item = wapp_char_array_get(other, item_index); ++item_index; @@ -499,12 +507,12 @@ void wapp_char_array_extend_capped(CharArray *array, const CharArray *other) { } void wapp_char_array_clear(CharArray *array) { - assert(array != NULL); + wapp_debug_assert(array != NULL, "`array` should not be NULL"); array->count = 0; } void wapp_char_array_copy_capped(const CharArray *src, CharArray *dst) { - assert(src != NULL && dst != NULL); + wapp_debug_assert(src != NULL && dst != NULL, "`src` and `dst` should not be NULL"); wapp_char_array_clear(dst); @@ -514,7 +522,7 @@ void wapp_char_array_copy_capped(const CharArray *src, CharArray *dst) { // MSVC Spectre mitigation warnings u64 to_copy = src->count < dst->capacity ? src->count : dst->capacity; u64 item_index = 0; - bool running = true; + b32 running = true; while (running) { item = wapp_char_array_get(src, item_index); ++item_index; @@ -529,7 +537,7 @@ void wapp_char_array_copy_capped(const CharArray *src, CharArray *dst) { } CharArray *wapp_char_array_append_alloc(const Allocator *allocator, CharArray *array, char *item) { - assert(allocator != NULL && array != NULL); + wapp_debug_assert(allocator != NULL && array != NULL, "`allocator` and `array` should not be NULL"); CharArray *output = array; @@ -550,7 +558,7 @@ RETURN_CHAR_ARRAY_APPEND_ALLOC: } CharArray *wapp_char_array_extend_alloc(const Allocator *allocator, CharArray *array, const CharArray *other) { - assert(allocator != NULL && array != NULL && other != NULL); + wapp_debug_assert(allocator != NULL && array != NULL && other != NULL, "`allocator`, `array` and `other` should not be NULL"); CharArray *output = array; @@ -572,7 +580,7 @@ RETURN_CHAR_ARRAY_EXTEND_ALLOC: } CharArray *wapp_char_array_copy_alloc(const Allocator *allocator, const CharArray *src, CharArray *dst) { - assert(allocator != NULL && src != NULL && dst != NULL); + wapp_debug_assert(allocator != NULL && src != NULL && dst != NULL, "`allocator`, `src` and `dst` should not be NULL"); CharArray *output = dst; @@ -600,7 +608,8 @@ char *_char_array_pop(CharArray *array) { } c8 *wapp_c8_array_get(const C8Array *array, u64 index) { - 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 (c8 *)ptr; @@ -613,17 +622,18 @@ void wapp_c8_array_set(C8Array *array, u64 index, c8 *item) { } void wapp_c8_array_append_capped(C8Array *array, c8 *item) { - 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_c8_array_set(array, index, item); } void wapp_c8_array_extend_capped(C8Array *array, const C8Array *other) { - 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"); c8 *item; @@ -631,7 +641,7 @@ void wapp_c8_array_extend_capped(C8Array *array, const C8Array *other) { // MSVC Spectre mitigation warnings u64 items_to_add = other->count; u64 item_index = 0; - bool running = true; + b32 running = true; while (running) { item = wapp_c8_array_get(other, item_index); ++item_index; @@ -646,12 +656,12 @@ void wapp_c8_array_extend_capped(C8Array *array, const C8Array *other) { } void wapp_c8_array_clear(C8Array *array) { - assert(array != NULL); + wapp_debug_assert(array != NULL, "`array` should not be NULL"); array->count = 0; } void wapp_c8_array_copy_capped(const C8Array *src, C8Array *dst) { - assert(src != NULL && dst != NULL); + wapp_debug_assert(src != NULL && dst != NULL, "`src` and `dst` should not be NULL"); wapp_c8_array_clear(dst); @@ -661,7 +671,7 @@ void wapp_c8_array_copy_capped(const C8Array *src, C8Array *dst) { // MSVC Spectre mitigation warnings u64 to_copy = src->count < dst->capacity ? src->count : dst->capacity; u64 item_index = 0; - bool running = true; + b32 running = true; while (running) { item = wapp_c8_array_get(src, item_index); ++item_index; @@ -676,7 +686,7 @@ void wapp_c8_array_copy_capped(const C8Array *src, C8Array *dst) { } C8Array *wapp_c8_array_append_alloc(const Allocator *allocator, C8Array *array, c8 *item) { - assert(allocator != NULL && array != NULL); + wapp_debug_assert(allocator != NULL && array != NULL, "`allocator` and `array` should not be NULL"); C8Array *output = array; @@ -697,7 +707,7 @@ RETURN_C8_ARRAY_APPEND_ALLOC: } C8Array *wapp_c8_array_extend_alloc(const Allocator *allocator, C8Array *array, const C8Array *other) { - assert(allocator != NULL && array != NULL && other != NULL); + wapp_debug_assert(allocator != NULL && array != NULL && other != NULL, "`allocator`, `array` and `other` should not be NULL"); C8Array *output = array; @@ -719,7 +729,7 @@ RETURN_C8_ARRAY_EXTEND_ALLOC: } C8Array *wapp_c8_array_copy_alloc(const Allocator *allocator, const C8Array *src, C8Array *dst) { - assert(allocator != NULL && src != NULL && dst != NULL); + wapp_debug_assert(allocator != NULL && src != NULL && dst != NULL, "`allocator`, `src` and `dst` should not be NULL"); C8Array *output = dst; @@ -747,7 +757,8 @@ c8 *_c8_array_pop(C8Array *array) { } c16 *wapp_c16_array_get(const C16Array *array, u64 index) { - 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 (c16 *)ptr; @@ -760,17 +771,18 @@ void wapp_c16_array_set(C16Array *array, u64 index, c16 *item) { } void wapp_c16_array_append_capped(C16Array *array, c16 *item) { - 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_c16_array_set(array, index, item); } void wapp_c16_array_extend_capped(C16Array *array, const C16Array *other) { - 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"); c16 *item; @@ -778,7 +790,7 @@ void wapp_c16_array_extend_capped(C16Array *array, const C16Array *other) { // MSVC Spectre mitigation warnings u64 items_to_add = other->count; u64 item_index = 0; - bool running = true; + b32 running = true; while (running) { item = wapp_c16_array_get(other, item_index); ++item_index; @@ -793,12 +805,12 @@ void wapp_c16_array_extend_capped(C16Array *array, const C16Array *other) { } void wapp_c16_array_clear(C16Array *array) { - assert(array != NULL); + wapp_debug_assert(array != NULL, "`array` should not be NULL"); array->count = 0; } void wapp_c16_array_copy_capped(const C16Array *src, C16Array *dst) { - assert(src != NULL && dst != NULL); + wapp_debug_assert(src != NULL && dst != NULL, "`src` and `dst` should not be NULL"); wapp_c16_array_clear(dst); @@ -808,7 +820,7 @@ void wapp_c16_array_copy_capped(const C16Array *src, C16Array *dst) { // MSVC Spectre mitigation warnings u64 to_copy = src->count < dst->capacity ? src->count : dst->capacity; u64 item_index = 0; - bool running = true; + b32 running = true; while (running) { item = wapp_c16_array_get(src, item_index); ++item_index; @@ -823,7 +835,7 @@ void wapp_c16_array_copy_capped(const C16Array *src, C16Array *dst) { } C16Array *wapp_c16_array_append_alloc(const Allocator *allocator, C16Array *array, c16 *item) { - assert(allocator != NULL && array != NULL); + wapp_debug_assert(allocator != NULL && array != NULL, "`allocator` and `array` should not be NULL"); C16Array *output = array; @@ -844,7 +856,7 @@ RETURN_C16_ARRAY_APPEND_ALLOC: } C16Array *wapp_c16_array_extend_alloc(const Allocator *allocator, C16Array *array, const C16Array *other) { - assert(allocator != NULL && array != NULL && other != NULL); + wapp_debug_assert(allocator != NULL && array != NULL && other != NULL, "`allocator`, `array` and `other` should not be NULL"); C16Array *output = array; @@ -866,7 +878,7 @@ RETURN_C16_ARRAY_EXTEND_ALLOC: } C16Array *wapp_c16_array_copy_alloc(const Allocator *allocator, const C16Array *src, C16Array *dst) { - assert(allocator != NULL && src != NULL && dst != NULL); + wapp_debug_assert(allocator != NULL && src != NULL && dst != NULL, "`allocator`, `src` and `dst` should not be NULL"); C16Array *output = dst; @@ -894,7 +906,8 @@ c16 *_c16_array_pop(C16Array *array) { } c32 *wapp_c32_array_get(const C32Array *array, u64 index) { - 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 (c32 *)ptr; @@ -907,17 +920,18 @@ void wapp_c32_array_set(C32Array *array, u64 index, c32 *item) { } void wapp_c32_array_append_capped(C32Array *array, c32 *item) { - 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_c32_array_set(array, index, item); } void wapp_c32_array_extend_capped(C32Array *array, const C32Array *other) { - 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"); c32 *item; @@ -925,7 +939,7 @@ void wapp_c32_array_extend_capped(C32Array *array, const C32Array *other) { // MSVC Spectre mitigation warnings u64 items_to_add = other->count; u64 item_index = 0; - bool running = true; + b32 running = true; while (running) { item = wapp_c32_array_get(other, item_index); ++item_index; @@ -940,12 +954,12 @@ void wapp_c32_array_extend_capped(C32Array *array, const C32Array *other) { } void wapp_c32_array_clear(C32Array *array) { - assert(array != NULL); + wapp_debug_assert(array != NULL, "`array` should not be NULL"); array->count = 0; } void wapp_c32_array_copy_capped(const C32Array *src, C32Array *dst) { - assert(src != NULL && dst != NULL); + wapp_debug_assert(src != NULL && dst != NULL, "`src` and `dst` should not be NULL"); wapp_c32_array_clear(dst); @@ -955,7 +969,7 @@ void wapp_c32_array_copy_capped(const C32Array *src, C32Array *dst) { // MSVC Spectre mitigation warnings u64 to_copy = src->count < dst->capacity ? src->count : dst->capacity; u64 item_index = 0; - bool running = true; + b32 running = true; while (running) { item = wapp_c32_array_get(src, item_index); ++item_index; @@ -970,7 +984,7 @@ void wapp_c32_array_copy_capped(const C32Array *src, C32Array *dst) { } C32Array *wapp_c32_array_append_alloc(const Allocator *allocator, C32Array *array, c32 *item) { - assert(allocator != NULL && array != NULL); + wapp_debug_assert(allocator != NULL && array != NULL, "`allocator` and `array` should not be NULL"); C32Array *output = array; @@ -991,7 +1005,7 @@ RETURN_C32_ARRAY_APPEND_ALLOC: } C32Array *wapp_c32_array_extend_alloc(const Allocator *allocator, C32Array *array, const C32Array *other) { - assert(allocator != NULL && array != NULL && other != NULL); + wapp_debug_assert(allocator != NULL && array != NULL && other != NULL, "`allocator`, `array` and `other` should not be NULL"); C32Array *output = array; @@ -1013,7 +1027,7 @@ RETURN_C32_ARRAY_EXTEND_ALLOC: } C32Array *wapp_c32_array_copy_alloc(const Allocator *allocator, const C32Array *src, C32Array *dst) { - assert(allocator != NULL && src != NULL && dst != NULL); + wapp_debug_assert(allocator != NULL && src != NULL && dst != NULL, "`allocator`, `src` and `dst` should not be NULL"); C32Array *output = dst; @@ -1041,7 +1055,8 @@ c32 *_c32_array_pop(C32Array *array) { } i8 *wapp_i8_array_get(const I8Array *array, u64 index) { - 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 (i8 *)ptr; @@ -1054,17 +1069,18 @@ void wapp_i8_array_set(I8Array *array, u64 index, i8 *item) { } void wapp_i8_array_append_capped(I8Array *array, i8 *item) { - 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_i8_array_set(array, index, item); } void wapp_i8_array_extend_capped(I8Array *array, const I8Array *other) { - 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"); i8 *item; @@ -1072,7 +1088,7 @@ void wapp_i8_array_extend_capped(I8Array *array, const I8Array *other) { // MSVC Spectre mitigation warnings u64 items_to_add = other->count; u64 item_index = 0; - bool running = true; + b32 running = true; while (running) { item = wapp_i8_array_get(other, item_index); ++item_index; @@ -1087,12 +1103,12 @@ void wapp_i8_array_extend_capped(I8Array *array, const I8Array *other) { } void wapp_i8_array_clear(I8Array *array) { - assert(array != NULL); + wapp_debug_assert(array != NULL, "`array` should not be NULL"); array->count = 0; } void wapp_i8_array_copy_capped(const I8Array *src, I8Array *dst) { - assert(src != NULL && dst != NULL); + wapp_debug_assert(src != NULL && dst != NULL, "`src` and `dst` should not be NULL"); wapp_i8_array_clear(dst); @@ -1102,7 +1118,7 @@ void wapp_i8_array_copy_capped(const I8Array *src, I8Array *dst) { // MSVC Spectre mitigation warnings u64 to_copy = src->count < dst->capacity ? src->count : dst->capacity; u64 item_index = 0; - bool running = true; + b32 running = true; while (running) { item = wapp_i8_array_get(src, item_index); ++item_index; @@ -1117,7 +1133,7 @@ void wapp_i8_array_copy_capped(const I8Array *src, I8Array *dst) { } I8Array *wapp_i8_array_append_alloc(const Allocator *allocator, I8Array *array, i8 *item) { - assert(allocator != NULL && array != NULL); + wapp_debug_assert(allocator != NULL && array != NULL, "`allocator` and `array` should not be NULL"); I8Array *output = array; @@ -1138,7 +1154,7 @@ RETURN_I8_ARRAY_APPEND_ALLOC: } I8Array *wapp_i8_array_extend_alloc(const Allocator *allocator, I8Array *array, const I8Array *other) { - assert(allocator != NULL && array != NULL && other != NULL); + wapp_debug_assert(allocator != NULL && array != NULL && other != NULL, "`allocator`, `array` and `other` should not be NULL"); I8Array *output = array; @@ -1160,7 +1176,7 @@ RETURN_I8_ARRAY_EXTEND_ALLOC: } I8Array *wapp_i8_array_copy_alloc(const Allocator *allocator, const I8Array *src, I8Array *dst) { - assert(allocator != NULL && src != NULL && dst != NULL); + wapp_debug_assert(allocator != NULL && src != NULL && dst != NULL, "`allocator`, `src` and `dst` should not be NULL"); I8Array *output = dst; @@ -1188,7 +1204,8 @@ i8 *_i8_array_pop(I8Array *array) { } i16 *wapp_i16_array_get(const I16Array *array, u64 index) { - 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 (i16 *)ptr; @@ -1201,17 +1218,18 @@ void wapp_i16_array_set(I16Array *array, u64 index, i16 *item) { } void wapp_i16_array_append_capped(I16Array *array, i16 *item) { - 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_i16_array_set(array, index, item); } void wapp_i16_array_extend_capped(I16Array *array, const I16Array *other) { - 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"); i16 *item; @@ -1219,7 +1237,7 @@ void wapp_i16_array_extend_capped(I16Array *array, const I16Array *other) { // MSVC Spectre mitigation warnings u64 items_to_add = other->count; u64 item_index = 0; - bool running = true; + b32 running = true; while (running) { item = wapp_i16_array_get(other, item_index); ++item_index; @@ -1234,12 +1252,12 @@ void wapp_i16_array_extend_capped(I16Array *array, const I16Array *other) { } void wapp_i16_array_clear(I16Array *array) { - assert(array != NULL); + wapp_debug_assert(array != NULL, "`array` should not be NULL"); array->count = 0; } void wapp_i16_array_copy_capped(const I16Array *src, I16Array *dst) { - assert(src != NULL && dst != NULL); + wapp_debug_assert(src != NULL && dst != NULL, "`src` and `dst` should not be NULL"); wapp_i16_array_clear(dst); @@ -1249,7 +1267,7 @@ void wapp_i16_array_copy_capped(const I16Array *src, I16Array *dst) { // MSVC Spectre mitigation warnings u64 to_copy = src->count < dst->capacity ? src->count : dst->capacity; u64 item_index = 0; - bool running = true; + b32 running = true; while (running) { item = wapp_i16_array_get(src, item_index); ++item_index; @@ -1264,7 +1282,7 @@ void wapp_i16_array_copy_capped(const I16Array *src, I16Array *dst) { } I16Array *wapp_i16_array_append_alloc(const Allocator *allocator, I16Array *array, i16 *item) { - assert(allocator != NULL && array != NULL); + wapp_debug_assert(allocator != NULL && array != NULL, "`allocator` and `array` should not be NULL"); I16Array *output = array; @@ -1285,7 +1303,7 @@ RETURN_I16_ARRAY_APPEND_ALLOC: } I16Array *wapp_i16_array_extend_alloc(const Allocator *allocator, I16Array *array, const I16Array *other) { - assert(allocator != NULL && array != NULL && other != NULL); + wapp_debug_assert(allocator != NULL && array != NULL && other != NULL, "`allocator`, `array` and `other` should not be NULL"); I16Array *output = array; @@ -1307,7 +1325,7 @@ RETURN_I16_ARRAY_EXTEND_ALLOC: } I16Array *wapp_i16_array_copy_alloc(const Allocator *allocator, const I16Array *src, I16Array *dst) { - assert(allocator != NULL && src != NULL && dst != NULL); + wapp_debug_assert(allocator != NULL && src != NULL && dst != NULL, "`allocator`, `src` and `dst` should not be NULL"); I16Array *output = dst; @@ -1335,7 +1353,8 @@ i16 *_i16_array_pop(I16Array *array) { } i32 *wapp_i32_array_get(const I32Array *array, u64 index) { - 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 (i32 *)ptr; @@ -1348,17 +1367,18 @@ void wapp_i32_array_set(I32Array *array, u64 index, i32 *item) { } void wapp_i32_array_append_capped(I32Array *array, i32 *item) { - 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_i32_array_set(array, index, item); } void wapp_i32_array_extend_capped(I32Array *array, const I32Array *other) { - 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"); i32 *item; @@ -1366,7 +1386,7 @@ void wapp_i32_array_extend_capped(I32Array *array, const I32Array *other) { // MSVC Spectre mitigation warnings u64 items_to_add = other->count; u64 item_index = 0; - bool running = true; + b32 running = true; while (running) { item = wapp_i32_array_get(other, item_index); ++item_index; @@ -1381,12 +1401,12 @@ void wapp_i32_array_extend_capped(I32Array *array, const I32Array *other) { } void wapp_i32_array_clear(I32Array *array) { - assert(array != NULL); + wapp_debug_assert(array != NULL, "`array` should not be NULL"); array->count = 0; } void wapp_i32_array_copy_capped(const I32Array *src, I32Array *dst) { - assert(src != NULL && dst != NULL); + wapp_debug_assert(src != NULL && dst != NULL, "`src` and `dst` should not be NULL"); wapp_i32_array_clear(dst); @@ -1396,7 +1416,7 @@ void wapp_i32_array_copy_capped(const I32Array *src, I32Array *dst) { // MSVC Spectre mitigation warnings u64 to_copy = src->count < dst->capacity ? src->count : dst->capacity; u64 item_index = 0; - bool running = true; + b32 running = true; while (running) { item = wapp_i32_array_get(src, item_index); ++item_index; @@ -1411,7 +1431,7 @@ void wapp_i32_array_copy_capped(const I32Array *src, I32Array *dst) { } I32Array *wapp_i32_array_append_alloc(const Allocator *allocator, I32Array *array, i32 *item) { - assert(allocator != NULL && array != NULL); + wapp_debug_assert(allocator != NULL && array != NULL, "`allocator` and `array` should not be NULL"); I32Array *output = array; @@ -1432,7 +1452,7 @@ RETURN_I32_ARRAY_APPEND_ALLOC: } I32Array *wapp_i32_array_extend_alloc(const Allocator *allocator, I32Array *array, const I32Array *other) { - assert(allocator != NULL && array != NULL && other != NULL); + wapp_debug_assert(allocator != NULL && array != NULL && other != NULL, "`allocator`, `array` and `other` should not be NULL"); I32Array *output = array; @@ -1454,7 +1474,7 @@ RETURN_I32_ARRAY_EXTEND_ALLOC: } I32Array *wapp_i32_array_copy_alloc(const Allocator *allocator, const I32Array *src, I32Array *dst) { - assert(allocator != NULL && src != NULL && dst != NULL); + wapp_debug_assert(allocator != NULL && src != NULL && dst != NULL, "`allocator`, `src` and `dst` should not be NULL"); I32Array *output = dst; @@ -1482,7 +1502,8 @@ i32 *_i32_array_pop(I32Array *array) { } i64 *wapp_i64_array_get(const I64Array *array, u64 index) { - 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 (i64 *)ptr; @@ -1495,17 +1516,18 @@ void wapp_i64_array_set(I64Array *array, u64 index, i64 *item) { } void wapp_i64_array_append_capped(I64Array *array, i64 *item) { - 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_i64_array_set(array, index, item); } void wapp_i64_array_extend_capped(I64Array *array, const I64Array *other) { - 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"); i64 *item; @@ -1513,7 +1535,7 @@ void wapp_i64_array_extend_capped(I64Array *array, const I64Array *other) { // MSVC Spectre mitigation warnings u64 items_to_add = other->count; u64 item_index = 0; - bool running = true; + b32 running = true; while (running) { item = wapp_i64_array_get(other, item_index); ++item_index; @@ -1528,12 +1550,12 @@ void wapp_i64_array_extend_capped(I64Array *array, const I64Array *other) { } void wapp_i64_array_clear(I64Array *array) { - assert(array != NULL); + wapp_debug_assert(array != NULL, "`array` should not be NULL"); array->count = 0; } void wapp_i64_array_copy_capped(const I64Array *src, I64Array *dst) { - assert(src != NULL && dst != NULL); + wapp_debug_assert(src != NULL && dst != NULL, "`src` and `dst` should not be NULL"); wapp_i64_array_clear(dst); @@ -1543,7 +1565,7 @@ void wapp_i64_array_copy_capped(const I64Array *src, I64Array *dst) { // MSVC Spectre mitigation warnings u64 to_copy = src->count < dst->capacity ? src->count : dst->capacity; u64 item_index = 0; - bool running = true; + b32 running = true; while (running) { item = wapp_i64_array_get(src, item_index); ++item_index; @@ -1558,7 +1580,7 @@ void wapp_i64_array_copy_capped(const I64Array *src, I64Array *dst) { } I64Array *wapp_i64_array_append_alloc(const Allocator *allocator, I64Array *array, i64 *item) { - assert(allocator != NULL && array != NULL); + wapp_debug_assert(allocator != NULL && array != NULL, "`allocator` and `array` should not be NULL"); I64Array *output = array; @@ -1579,7 +1601,7 @@ RETURN_I64_ARRAY_APPEND_ALLOC: } I64Array *wapp_i64_array_extend_alloc(const Allocator *allocator, I64Array *array, const I64Array *other) { - assert(allocator != NULL && array != NULL && other != NULL); + wapp_debug_assert(allocator != NULL && array != NULL && other != NULL, "`allocator`, `array` and `other` should not be NULL"); I64Array *output = array; @@ -1601,7 +1623,7 @@ RETURN_I64_ARRAY_EXTEND_ALLOC: } I64Array *wapp_i64_array_copy_alloc(const Allocator *allocator, const I64Array *src, I64Array *dst) { - assert(allocator != NULL && src != NULL && dst != NULL); + wapp_debug_assert(allocator != NULL && src != NULL && dst != NULL, "`allocator`, `src` and `dst` should not be NULL"); I64Array *output = dst; @@ -1629,7 +1651,8 @@ i64 *_i64_array_pop(I64Array *array) { } u8 *wapp_u8_array_get(const U8Array *array, u64 index) { - 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 (u8 *)ptr; @@ -1642,17 +1665,18 @@ void wapp_u8_array_set(U8Array *array, u64 index, u8 *item) { } void wapp_u8_array_append_capped(U8Array *array, u8 *item) { - 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_u8_array_set(array, index, item); } void wapp_u8_array_extend_capped(U8Array *array, const U8Array *other) { - 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"); u8 *item; @@ -1660,7 +1684,7 @@ void wapp_u8_array_extend_capped(U8Array *array, const U8Array *other) { // MSVC Spectre mitigation warnings u64 items_to_add = other->count; u64 item_index = 0; - bool running = true; + b32 running = true; while (running) { item = wapp_u8_array_get(other, item_index); ++item_index; @@ -1675,12 +1699,12 @@ void wapp_u8_array_extend_capped(U8Array *array, const U8Array *other) { } void wapp_u8_array_clear(U8Array *array) { - assert(array != NULL); + wapp_debug_assert(array != NULL, "`array` should not be NULL"); array->count = 0; } void wapp_u8_array_copy_capped(const U8Array *src, U8Array *dst) { - assert(src != NULL && dst != NULL); + wapp_debug_assert(src != NULL && dst != NULL, "`src` and `dst` should not be NULL"); wapp_u8_array_clear(dst); @@ -1690,7 +1714,7 @@ void wapp_u8_array_copy_capped(const U8Array *src, U8Array *dst) { // MSVC Spectre mitigation warnings u64 to_copy = src->count < dst->capacity ? src->count : dst->capacity; u64 item_index = 0; - bool running = true; + b32 running = true; while (running) { item = wapp_u8_array_get(src, item_index); ++item_index; @@ -1705,7 +1729,7 @@ void wapp_u8_array_copy_capped(const U8Array *src, U8Array *dst) { } U8Array *wapp_u8_array_append_alloc(const Allocator *allocator, U8Array *array, u8 *item) { - assert(allocator != NULL && array != NULL); + wapp_debug_assert(allocator != NULL && array != NULL, "`allocator` and `array` should not be NULL"); U8Array *output = array; @@ -1726,7 +1750,7 @@ RETURN_U8_ARRAY_APPEND_ALLOC: } U8Array *wapp_u8_array_extend_alloc(const Allocator *allocator, U8Array *array, const U8Array *other) { - assert(allocator != NULL && array != NULL && other != NULL); + wapp_debug_assert(allocator != NULL && array != NULL && other != NULL, "`allocator`, `array` and `other` should not be NULL"); U8Array *output = array; @@ -1748,7 +1772,7 @@ RETURN_U8_ARRAY_EXTEND_ALLOC: } U8Array *wapp_u8_array_copy_alloc(const Allocator *allocator, const U8Array *src, U8Array *dst) { - assert(allocator != NULL && src != NULL && dst != NULL); + wapp_debug_assert(allocator != NULL && src != NULL && dst != NULL, "`allocator`, `src` and `dst` should not be NULL"); U8Array *output = dst; @@ -1776,7 +1800,8 @@ u8 *_u8_array_pop(U8Array *array) { } u16 *wapp_u16_array_get(const U16Array *array, u64 index) { - 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 (u16 *)ptr; @@ -1789,17 +1814,18 @@ void wapp_u16_array_set(U16Array *array, u64 index, u16 *item) { } void wapp_u16_array_append_capped(U16Array *array, u16 *item) { - 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_u16_array_set(array, index, item); } void wapp_u16_array_extend_capped(U16Array *array, const U16Array *other) { - 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"); u16 *item; @@ -1807,7 +1833,7 @@ void wapp_u16_array_extend_capped(U16Array *array, const U16Array *other) { // MSVC Spectre mitigation warnings u64 items_to_add = other->count; u64 item_index = 0; - bool running = true; + b32 running = true; while (running) { item = wapp_u16_array_get(other, item_index); ++item_index; @@ -1822,12 +1848,12 @@ void wapp_u16_array_extend_capped(U16Array *array, const U16Array *other) { } void wapp_u16_array_clear(U16Array *array) { - assert(array != NULL); + wapp_debug_assert(array != NULL, "`array` should not be NULL"); array->count = 0; } void wapp_u16_array_copy_capped(const U16Array *src, U16Array *dst) { - assert(src != NULL && dst != NULL); + wapp_debug_assert(src != NULL && dst != NULL, "`src` and `dst` should not be NULL"); wapp_u16_array_clear(dst); @@ -1837,7 +1863,7 @@ void wapp_u16_array_copy_capped(const U16Array *src, U16Array *dst) { // MSVC Spectre mitigation warnings u64 to_copy = src->count < dst->capacity ? src->count : dst->capacity; u64 item_index = 0; - bool running = true; + b32 running = true; while (running) { item = wapp_u16_array_get(src, item_index); ++item_index; @@ -1852,7 +1878,7 @@ void wapp_u16_array_copy_capped(const U16Array *src, U16Array *dst) { } U16Array *wapp_u16_array_append_alloc(const Allocator *allocator, U16Array *array, u16 *item) { - assert(allocator != NULL && array != NULL); + wapp_debug_assert(allocator != NULL && array != NULL, "`allocator` and `array` should not be NULL"); U16Array *output = array; @@ -1873,7 +1899,7 @@ RETURN_U16_ARRAY_APPEND_ALLOC: } U16Array *wapp_u16_array_extend_alloc(const Allocator *allocator, U16Array *array, const U16Array *other) { - assert(allocator != NULL && array != NULL && other != NULL); + wapp_debug_assert(allocator != NULL && array != NULL && other != NULL, "`allocator`, `array` and `other` should not be NULL"); U16Array *output = array; @@ -1895,7 +1921,7 @@ RETURN_U16_ARRAY_EXTEND_ALLOC: } U16Array *wapp_u16_array_copy_alloc(const Allocator *allocator, const U16Array *src, U16Array *dst) { - assert(allocator != NULL && src != NULL && dst != NULL); + wapp_debug_assert(allocator != NULL && src != NULL && dst != NULL, "`allocator`, `src` and `dst` should not be NULL"); U16Array *output = dst; @@ -1923,7 +1949,8 @@ u16 *_u16_array_pop(U16Array *array) { } u32 *wapp_u32_array_get(const U32Array *array, u64 index) { - 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 (u32 *)ptr; @@ -1936,17 +1963,18 @@ void wapp_u32_array_set(U32Array *array, u64 index, u32 *item) { } void wapp_u32_array_append_capped(U32Array *array, u32 *item) { - 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_u32_array_set(array, index, item); } void wapp_u32_array_extend_capped(U32Array *array, const U32Array *other) { - 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"); u32 *item; @@ -1954,7 +1982,7 @@ void wapp_u32_array_extend_capped(U32Array *array, const U32Array *other) { // MSVC Spectre mitigation warnings u64 items_to_add = other->count; u64 item_index = 0; - bool running = true; + b32 running = true; while (running) { item = wapp_u32_array_get(other, item_index); ++item_index; @@ -1969,12 +1997,12 @@ void wapp_u32_array_extend_capped(U32Array *array, const U32Array *other) { } void wapp_u32_array_clear(U32Array *array) { - assert(array != NULL); + wapp_debug_assert(array != NULL, "`array` should not be NULL"); array->count = 0; } void wapp_u32_array_copy_capped(const U32Array *src, U32Array *dst) { - assert(src != NULL && dst != NULL); + wapp_debug_assert(src != NULL && dst != NULL, "`src` and `dst` should not be NULL"); wapp_u32_array_clear(dst); @@ -1984,7 +2012,7 @@ void wapp_u32_array_copy_capped(const U32Array *src, U32Array *dst) { // MSVC Spectre mitigation warnings u64 to_copy = src->count < dst->capacity ? src->count : dst->capacity; u64 item_index = 0; - bool running = true; + b32 running = true; while (running) { item = wapp_u32_array_get(src, item_index); ++item_index; @@ -1999,7 +2027,7 @@ void wapp_u32_array_copy_capped(const U32Array *src, U32Array *dst) { } U32Array *wapp_u32_array_append_alloc(const Allocator *allocator, U32Array *array, u32 *item) { - assert(allocator != NULL && array != NULL); + wapp_debug_assert(allocator != NULL && array != NULL, "`allocator` and `array` should not be NULL"); U32Array *output = array; @@ -2020,7 +2048,7 @@ RETURN_U32_ARRAY_APPEND_ALLOC: } U32Array *wapp_u32_array_extend_alloc(const Allocator *allocator, U32Array *array, const U32Array *other) { - assert(allocator != NULL && array != NULL && other != NULL); + wapp_debug_assert(allocator != NULL && array != NULL && other != NULL, "`allocator`, `array` and `other` should not be NULL"); U32Array *output = array; @@ -2042,7 +2070,7 @@ RETURN_U32_ARRAY_EXTEND_ALLOC: } U32Array *wapp_u32_array_copy_alloc(const Allocator *allocator, const U32Array *src, U32Array *dst) { - assert(allocator != NULL && src != NULL && dst != NULL); + wapp_debug_assert(allocator != NULL && src != NULL && dst != NULL, "`allocator`, `src` and `dst` should not be NULL"); U32Array *output = dst; @@ -2070,7 +2098,8 @@ u32 *_u32_array_pop(U32Array *array) { } u64 *wapp_u64_array_get(const U64Array *array, u64 index) { - 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 (u64 *)ptr; @@ -2083,17 +2112,18 @@ void wapp_u64_array_set(U64Array *array, u64 index, u64 *item) { } void wapp_u64_array_append_capped(U64Array *array, u64 *item) { - 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_u64_array_set(array, index, item); } void wapp_u64_array_extend_capped(U64Array *array, const U64Array *other) { - 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"); u64 *item; @@ -2101,7 +2131,7 @@ void wapp_u64_array_extend_capped(U64Array *array, const U64Array *other) { // MSVC Spectre mitigation warnings u64 items_to_add = other->count; u64 item_index = 0; - bool running = true; + b32 running = true; while (running) { item = wapp_u64_array_get(other, item_index); ++item_index; @@ -2116,12 +2146,12 @@ void wapp_u64_array_extend_capped(U64Array *array, const U64Array *other) { } void wapp_u64_array_clear(U64Array *array) { - assert(array != NULL); + wapp_debug_assert(array != NULL, "`array` should not be NULL"); array->count = 0; } void wapp_u64_array_copy_capped(const U64Array *src, U64Array *dst) { - assert(src != NULL && dst != NULL); + wapp_debug_assert(src != NULL && dst != NULL, "`src` and `dst` should not be NULL"); wapp_u64_array_clear(dst); @@ -2131,7 +2161,7 @@ void wapp_u64_array_copy_capped(const U64Array *src, U64Array *dst) { // MSVC Spectre mitigation warnings u64 to_copy = src->count < dst->capacity ? src->count : dst->capacity; u64 item_index = 0; - bool running = true; + b32 running = true; while (running) { item = wapp_u64_array_get(src, item_index); ++item_index; @@ -2146,7 +2176,7 @@ void wapp_u64_array_copy_capped(const U64Array *src, U64Array *dst) { } U64Array *wapp_u64_array_append_alloc(const Allocator *allocator, U64Array *array, u64 *item) { - assert(allocator != NULL && array != NULL); + wapp_debug_assert(allocator != NULL && array != NULL, "`allocator` and `array` should not be NULL"); U64Array *output = array; @@ -2167,7 +2197,7 @@ RETURN_U64_ARRAY_APPEND_ALLOC: } U64Array *wapp_u64_array_extend_alloc(const Allocator *allocator, U64Array *array, const U64Array *other) { - assert(allocator != NULL && array != NULL && other != NULL); + wapp_debug_assert(allocator != NULL && array != NULL && other != NULL, "`allocator`, `array` and `other` should not be NULL"); U64Array *output = array; @@ -2189,7 +2219,7 @@ RETURN_U64_ARRAY_EXTEND_ALLOC: } U64Array *wapp_u64_array_copy_alloc(const Allocator *allocator, const U64Array *src, U64Array *dst) { - assert(allocator != NULL && src != NULL && dst != NULL); + wapp_debug_assert(allocator != NULL && src != NULL && dst != NULL, "`allocator`, `src` and `dst` should not be NULL"); U64Array *output = dst; @@ -2217,7 +2247,8 @@ u64 *_u64_array_pop(U64Array *array) { } f32 *wapp_f32_array_get(const F32Array *array, u64 index) { - 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 (f32 *)ptr; @@ -2230,17 +2261,18 @@ void wapp_f32_array_set(F32Array *array, u64 index, f32 *item) { } void wapp_f32_array_append_capped(F32Array *array, f32 *item) { - 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_f32_array_set(array, index, item); } void wapp_f32_array_extend_capped(F32Array *array, const F32Array *other) { - 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"); f32 *item; @@ -2248,7 +2280,7 @@ void wapp_f32_array_extend_capped(F32Array *array, const F32Array *other) { // MSVC Spectre mitigation warnings u64 items_to_add = other->count; u64 item_index = 0; - bool running = true; + b32 running = true; while (running) { item = wapp_f32_array_get(other, item_index); ++item_index; @@ -2263,12 +2295,12 @@ void wapp_f32_array_extend_capped(F32Array *array, const F32Array *other) { } void wapp_f32_array_clear(F32Array *array) { - assert(array != NULL); + wapp_debug_assert(array != NULL, "`array` should not be NULL"); array->count = 0; } void wapp_f32_array_copy_capped(const F32Array *src, F32Array *dst) { - assert(src != NULL && dst != NULL); + wapp_debug_assert(src != NULL && dst != NULL, "`src` and `dst` should not be NULL"); wapp_f32_array_clear(dst); @@ -2278,7 +2310,7 @@ void wapp_f32_array_copy_capped(const F32Array *src, F32Array *dst) { // MSVC Spectre mitigation warnings u64 to_copy = src->count < dst->capacity ? src->count : dst->capacity; u64 item_index = 0; - bool running = true; + b32 running = true; while (running) { item = wapp_f32_array_get(src, item_index); ++item_index; @@ -2293,7 +2325,7 @@ void wapp_f32_array_copy_capped(const F32Array *src, F32Array *dst) { } F32Array *wapp_f32_array_append_alloc(const Allocator *allocator, F32Array *array, f32 *item) { - assert(allocator != NULL && array != NULL); + wapp_debug_assert(allocator != NULL && array != NULL, "`allocator` and `array` should not be NULL"); F32Array *output = array; @@ -2314,7 +2346,7 @@ RETURN_F32_ARRAY_APPEND_ALLOC: } F32Array *wapp_f32_array_extend_alloc(const Allocator *allocator, F32Array *array, const F32Array *other) { - assert(allocator != NULL && array != NULL && other != NULL); + wapp_debug_assert(allocator != NULL && array != NULL && other != NULL, "`allocator`, `array` and `other` should not be NULL"); F32Array *output = array; @@ -2336,7 +2368,7 @@ RETURN_F32_ARRAY_EXTEND_ALLOC: } F32Array *wapp_f32_array_copy_alloc(const Allocator *allocator, const F32Array *src, F32Array *dst) { - assert(allocator != NULL && src != NULL && dst != NULL); + wapp_debug_assert(allocator != NULL && src != NULL && dst != NULL, "`allocator`, `src` and `dst` should not be NULL"); F32Array *output = dst; @@ -2364,7 +2396,8 @@ f32 *_f32_array_pop(F32Array *array) { } f64 *wapp_f64_array_get(const F64Array *array, u64 index) { - 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 (f64 *)ptr; @@ -2377,17 +2410,18 @@ void wapp_f64_array_set(F64Array *array, u64 index, f64 *item) { } void wapp_f64_array_append_capped(F64Array *array, f64 *item) { - 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_f64_array_set(array, index, item); } void wapp_f64_array_extend_capped(F64Array *array, const F64Array *other) { - 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"); f64 *item; @@ -2395,7 +2429,7 @@ void wapp_f64_array_extend_capped(F64Array *array, const F64Array *other) { // MSVC Spectre mitigation warnings u64 items_to_add = other->count; u64 item_index = 0; - bool running = true; + b32 running = true; while (running) { item = wapp_f64_array_get(other, item_index); ++item_index; @@ -2410,12 +2444,12 @@ void wapp_f64_array_extend_capped(F64Array *array, const F64Array *other) { } void wapp_f64_array_clear(F64Array *array) { - assert(array != NULL); + wapp_debug_assert(array != NULL, "`array` should not be NULL"); array->count = 0; } void wapp_f64_array_copy_capped(const F64Array *src, F64Array *dst) { - assert(src != NULL && dst != NULL); + wapp_debug_assert(src != NULL && dst != NULL, "`src` and `dst` should not be NULL"); wapp_f64_array_clear(dst); @@ -2425,7 +2459,7 @@ void wapp_f64_array_copy_capped(const F64Array *src, F64Array *dst) { // MSVC Spectre mitigation warnings u64 to_copy = src->count < dst->capacity ? src->count : dst->capacity; u64 item_index = 0; - bool running = true; + b32 running = true; while (running) { item = wapp_f64_array_get(src, item_index); ++item_index; @@ -2440,7 +2474,7 @@ void wapp_f64_array_copy_capped(const F64Array *src, F64Array *dst) { } F64Array *wapp_f64_array_append_alloc(const Allocator *allocator, F64Array *array, f64 *item) { - assert(allocator != NULL && array != NULL); + wapp_debug_assert(allocator != NULL && array != NULL, "`allocator` and `array` should not be NULL"); F64Array *output = array; @@ -2461,7 +2495,7 @@ RETURN_F64_ARRAY_APPEND_ALLOC: } F64Array *wapp_f64_array_extend_alloc(const Allocator *allocator, F64Array *array, const F64Array *other) { - assert(allocator != NULL && array != NULL && other != NULL); + wapp_debug_assert(allocator != NULL && array != NULL && other != NULL, "`allocator`, `array` and `other` should not be NULL"); F64Array *output = array; @@ -2483,7 +2517,7 @@ RETURN_F64_ARRAY_EXTEND_ALLOC: } F64Array *wapp_f64_array_copy_alloc(const Allocator *allocator, const F64Array *src, F64Array *dst) { - assert(allocator != NULL && src != NULL && dst != NULL); + wapp_debug_assert(allocator != NULL && src != NULL && dst != NULL, "`allocator`, `src` and `dst` should not be NULL"); F64Array *output = dst; @@ -2511,7 +2545,8 @@ f64 *_f64_array_pop(F64Array *array) { } f128 *wapp_f128_array_get(const F128Array *array, u64 index) { - 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 (f128 *)ptr; @@ -2524,17 +2559,18 @@ void wapp_f128_array_set(F128Array *array, u64 index, f128 *item) { } void wapp_f128_array_append_capped(F128Array *array, f128 *item) { - 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_f128_array_set(array, index, item); } void wapp_f128_array_extend_capped(F128Array *array, const F128Array *other) { - 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"); f128 *item; @@ -2542,7 +2578,7 @@ void wapp_f128_array_extend_capped(F128Array *array, const F128Array *other) { // MSVC Spectre mitigation warnings u64 items_to_add = other->count; u64 item_index = 0; - bool running = true; + b32 running = true; while (running) { item = wapp_f128_array_get(other, item_index); ++item_index; @@ -2557,12 +2593,12 @@ void wapp_f128_array_extend_capped(F128Array *array, const F128Array *other) { } void wapp_f128_array_clear(F128Array *array) { - assert(array != NULL); + wapp_debug_assert(array != NULL, "`array` should not be NULL"); array->count = 0; } void wapp_f128_array_copy_capped(const F128Array *src, F128Array *dst) { - assert(src != NULL && dst != NULL); + wapp_debug_assert(src != NULL && dst != NULL, "`src` and `dst` should not be NULL"); wapp_f128_array_clear(dst); @@ -2572,7 +2608,7 @@ void wapp_f128_array_copy_capped(const F128Array *src, F128Array *dst) { // MSVC Spectre mitigation warnings u64 to_copy = src->count < dst->capacity ? src->count : dst->capacity; u64 item_index = 0; - bool running = true; + b32 running = true; while (running) { item = wapp_f128_array_get(src, item_index); ++item_index; @@ -2587,7 +2623,7 @@ void wapp_f128_array_copy_capped(const F128Array *src, F128Array *dst) { } F128Array *wapp_f128_array_append_alloc(const Allocator *allocator, F128Array *array, f128 *item) { - assert(allocator != NULL && array != NULL); + wapp_debug_assert(allocator != NULL && array != NULL, "`allocator` and `array` should not be NULL"); F128Array *output = array; @@ -2608,7 +2644,7 @@ RETURN_F128_ARRAY_APPEND_ALLOC: } F128Array *wapp_f128_array_extend_alloc(const Allocator *allocator, F128Array *array, const F128Array *other) { - assert(allocator != NULL && array != NULL && other != NULL); + wapp_debug_assert(allocator != NULL && array != NULL && other != NULL, "`allocator`, `array` and `other` should not be NULL"); F128Array *output = array; @@ -2630,7 +2666,7 @@ RETURN_F128_ARRAY_EXTEND_ALLOC: } F128Array *wapp_f128_array_copy_alloc(const Allocator *allocator, const F128Array *src, F128Array *dst) { - assert(allocator != NULL && src != NULL && dst != NULL); + wapp_debug_assert(allocator != NULL && src != NULL && dst != NULL, "`allocator`, `src` and `dst` should not be NULL"); F128Array *output = dst; @@ -2658,7 +2694,8 @@ f128 *_f128_array_pop(F128Array *array) { } iptr *wapp_iptr_array_get(const IptrArray *array, u64 index) { - 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 (iptr *)ptr; @@ -2671,17 +2708,18 @@ void wapp_iptr_array_set(IptrArray *array, u64 index, iptr *item) { } void wapp_iptr_array_append_capped(IptrArray *array, iptr *item) { - 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_iptr_array_set(array, index, item); } void wapp_iptr_array_extend_capped(IptrArray *array, const IptrArray *other) { - 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"); iptr *item; @@ -2689,7 +2727,7 @@ void wapp_iptr_array_extend_capped(IptrArray *array, const IptrArray *other) { // MSVC Spectre mitigation warnings u64 items_to_add = other->count; u64 item_index = 0; - bool running = true; + b32 running = true; while (running) { item = wapp_iptr_array_get(other, item_index); ++item_index; @@ -2704,12 +2742,12 @@ void wapp_iptr_array_extend_capped(IptrArray *array, const IptrArray *other) { } void wapp_iptr_array_clear(IptrArray *array) { - assert(array != NULL); + wapp_debug_assert(array != NULL, "`array` should not be NULL"); array->count = 0; } void wapp_iptr_array_copy_capped(const IptrArray *src, IptrArray *dst) { - assert(src != NULL && dst != NULL); + wapp_debug_assert(src != NULL && dst != NULL, "`src` and `dst` should not be NULL"); wapp_iptr_array_clear(dst); @@ -2719,7 +2757,7 @@ void wapp_iptr_array_copy_capped(const IptrArray *src, IptrArray *dst) { // MSVC Spectre mitigation warnings u64 to_copy = src->count < dst->capacity ? src->count : dst->capacity; u64 item_index = 0; - bool running = true; + b32 running = true; while (running) { item = wapp_iptr_array_get(src, item_index); ++item_index; @@ -2734,7 +2772,7 @@ void wapp_iptr_array_copy_capped(const IptrArray *src, IptrArray *dst) { } IptrArray *wapp_iptr_array_append_alloc(const Allocator *allocator, IptrArray *array, iptr *item) { - assert(allocator != NULL && array != NULL); + wapp_debug_assert(allocator != NULL && array != NULL, "`allocator` and `array` should not be NULL"); IptrArray *output = array; @@ -2755,7 +2793,7 @@ RETURN_IPTR_ARRAY_APPEND_ALLOC: } IptrArray *wapp_iptr_array_extend_alloc(const Allocator *allocator, IptrArray *array, const IptrArray *other) { - assert(allocator != NULL && array != NULL && other != NULL); + wapp_debug_assert(allocator != NULL && array != NULL && other != NULL, "`allocator`, `array` and `other` should not be NULL"); IptrArray *output = array; @@ -2777,7 +2815,7 @@ RETURN_IPTR_ARRAY_EXTEND_ALLOC: } IptrArray *wapp_iptr_array_copy_alloc(const Allocator *allocator, const IptrArray *src, IptrArray *dst) { - assert(allocator != NULL && src != NULL && dst != NULL); + wapp_debug_assert(allocator != NULL && src != NULL && dst != NULL, "`allocator`, `src` and `dst` should not be NULL"); IptrArray *output = dst; @@ -2805,7 +2843,8 @@ iptr *_iptr_array_pop(IptrArray *array) { } uptr *wapp_uptr_array_get(const UptrArray *array, u64 index) { - 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 (uptr *)ptr; @@ -2818,17 +2857,18 @@ void wapp_uptr_array_set(UptrArray *array, u64 index, uptr *item) { } void wapp_uptr_array_append_capped(UptrArray *array, uptr *item) { - 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_uptr_array_set(array, index, item); } void wapp_uptr_array_extend_capped(UptrArray *array, const UptrArray *other) { - 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"); uptr *item; @@ -2836,7 +2876,7 @@ void wapp_uptr_array_extend_capped(UptrArray *array, const UptrArray *other) { // MSVC Spectre mitigation warnings u64 items_to_add = other->count; u64 item_index = 0; - bool running = true; + b32 running = true; while (running) { item = wapp_uptr_array_get(other, item_index); ++item_index; @@ -2851,12 +2891,12 @@ void wapp_uptr_array_extend_capped(UptrArray *array, const UptrArray *other) { } void wapp_uptr_array_clear(UptrArray *array) { - assert(array != NULL); + wapp_debug_assert(array != NULL, "`array` should not be NULL"); array->count = 0; } void wapp_uptr_array_copy_capped(const UptrArray *src, UptrArray *dst) { - assert(src != NULL && dst != NULL); + wapp_debug_assert(src != NULL && dst != NULL, "`src` and `dst` should not be NULL"); wapp_uptr_array_clear(dst); @@ -2866,7 +2906,7 @@ void wapp_uptr_array_copy_capped(const UptrArray *src, UptrArray *dst) { // MSVC Spectre mitigation warnings u64 to_copy = src->count < dst->capacity ? src->count : dst->capacity; u64 item_index = 0; - bool running = true; + b32 running = true; while (running) { item = wapp_uptr_array_get(src, item_index); ++item_index; @@ -2881,7 +2921,7 @@ void wapp_uptr_array_copy_capped(const UptrArray *src, UptrArray *dst) { } UptrArray *wapp_uptr_array_append_alloc(const Allocator *allocator, UptrArray *array, uptr *item) { - assert(allocator != NULL && array != NULL); + wapp_debug_assert(allocator != NULL && array != NULL, "`allocator` and `array` should not be NULL"); UptrArray *output = array; @@ -2902,7 +2942,7 @@ RETURN_UPTR_ARRAY_APPEND_ALLOC: } UptrArray *wapp_uptr_array_extend_alloc(const Allocator *allocator, UptrArray *array, const UptrArray *other) { - assert(allocator != NULL && array != NULL && other != NULL); + wapp_debug_assert(allocator != NULL && array != NULL && other != NULL, "`allocator`, `array` and `other` should not be NULL"); UptrArray *output = array; @@ -2924,7 +2964,7 @@ RETURN_UPTR_ARRAY_EXTEND_ALLOC: } UptrArray *wapp_uptr_array_copy_alloc(const Allocator *allocator, const UptrArray *src, UptrArray *dst) { - assert(allocator != NULL && src != NULL && dst != NULL); + wapp_debug_assert(allocator != NULL && src != NULL && dst != NULL, "`allocator`, `src` and `dst` should not be NULL"); UptrArray *output = dst; @@ -2952,7 +2992,7 @@ uptr *_uptr_array_pop(UptrArray *array) { } VoidPArray *_array_alloc_capacity(const Allocator *allocator, u64 capacity, u64 item_size) { - assert(allocator != NULL); + wapp_debug_assert(allocator != NULL, "`array` should not be NULL"); u64 allocation_size = sizeof(VoidPArray) + item_size * capacity; VoidPArray *array = wapp_mem_allocator_alloc(allocator, allocation_size); diff --git a/src/primitives/array/array.h b/src/primitives/array/array.h index c4efc2a..da31ac8 100644 --- a/src/primitives/array/array.h +++ b/src/primitives/array/array.h @@ -5,11 +5,11 @@ #ifndef ARRAY_H #define ARRAY_H +#include "../../common/aliases/aliases.h" #include "../mem_allocator/mem_allocator.h" #include "../../common/misc/misc_utils.h" #include "../../common/aliases/aliases.h" #include "../../common/platform/platform.h" -#include #define wapp_str8_array(...) ((Str8Array){ \ .items = (Str8[wapp_misc_utils_u64_round_up_pow2(wapp_misc_utils_va_args_count(Str8, __VA_ARGS__) * 2)]){__VA_ARGS__}, \ @@ -35,17 +35,17 @@ *_void_ptr_array_pop(ARRAY_PTR) : \ (void *){0} \ ) -#define wapp_bool_array(...) ((BoolArray){ \ - .items = (bool[wapp_misc_utils_u64_round_up_pow2(wapp_misc_utils_va_args_count(bool, __VA_ARGS__) * 2)]){__VA_ARGS__}, \ - .count = wapp_misc_utils_va_args_count(bool, __VA_ARGS__), \ - .capacity = wapp_misc_utils_u64_round_up_pow2(wapp_misc_utils_va_args_count(bool, __VA_ARGS__) * 2), \ - .item_size = sizeof(bool) \ +#define wapp_b32_array(...) ((B32Array){ \ + .items = (b32[wapp_misc_utils_u64_round_up_pow2(wapp_misc_utils_va_args_count(b32, __VA_ARGS__) * 2)]){__VA_ARGS__}, \ + .count = wapp_misc_utils_va_args_count(b32, __VA_ARGS__), \ + .capacity = wapp_misc_utils_u64_round_up_pow2(wapp_misc_utils_va_args_count(b32, __VA_ARGS__) * 2), \ + .item_size = sizeof(b32) \ }) -#define wapp_bool_array_with_capacity(CAPACITY) ((BoolArray){.items = (bool[CAPACITY]){0}, .count = 0, .capacity = CAPACITY, .item_size = sizeof(bool)}) -#define wapp_bool_array_alloc_capacity(ALLOCATOR_PTR, CAPACITY) ((BoolArray *)_array_alloc_capacity(ALLOCATOR_PTR, CAPACITY, sizeof(bool))) -#define wapp_bool_array_pop(ARRAY_PTR) (ARRAY_PTR != NULL && (ARRAY_PTR)->count > 0 ? \ - *_bool_array_pop(ARRAY_PTR) : \ - (bool){0} \ +#define wapp_b32_array_with_capacity(CAPACITY) ((B32Array){.items = (b32[CAPACITY]){0}, .count = 0, .capacity = CAPACITY, .item_size = sizeof(b32)}) +#define wapp_b32_array_alloc_capacity(ALLOCATOR_PTR, CAPACITY) ((B32Array *)_array_alloc_capacity(ALLOCATOR_PTR, CAPACITY, sizeof(b32))) +#define wapp_b32_array_pop(ARRAY_PTR) (ARRAY_PTR != NULL && (ARRAY_PTR)->count > 0 ? \ + *_b32_array_pop(ARRAY_PTR) : \ + (b32){0} \ ) #define wapp_char_array(...) ((CharArray){ \ .items = (char[wapp_misc_utils_u64_round_up_pow2(wapp_misc_utils_va_args_count(char, __VA_ARGS__) * 2)]){__VA_ARGS__}, \ @@ -270,9 +270,9 @@ struct VoidPArray { u64 item_size; }; -typedef struct BoolArray BoolArray; -struct BoolArray { - bool *items; +typedef struct B32Array B32Array; +struct B32Array { + b32 *items; u64 count; u64 capacity; u64 item_size; @@ -434,16 +434,16 @@ VoidPArray *wapp_void_ptr_array_append_alloc(const Allocator *allocator, VoidPAr VoidPArray *wapp_void_ptr_array_extend_alloc(const Allocator *allocator, VoidPArray *array, const VoidPArray *other); VoidPArray *wapp_void_ptr_array_copy_alloc(const Allocator *allocator, const VoidPArray *src, VoidPArray *dst); void * *_void_ptr_array_pop(VoidPArray *array); -bool *wapp_bool_array_get(const BoolArray *array, u64 index); -void wapp_bool_array_set(BoolArray *array, u64 index, bool *item); -void wapp_bool_array_append_capped(BoolArray *array, bool *item); -void wapp_bool_array_extend_capped(BoolArray *array, const BoolArray *other); -void wapp_bool_array_clear(BoolArray *array); -void wapp_bool_array_copy_capped(const BoolArray *src, BoolArray *dst); -BoolArray *wapp_bool_array_append_alloc(const Allocator *allocator, BoolArray *array, bool *item); -BoolArray *wapp_bool_array_extend_alloc(const Allocator *allocator, BoolArray *array, const BoolArray *other); -BoolArray *wapp_bool_array_copy_alloc(const Allocator *allocator, const BoolArray *src, BoolArray *dst); -bool *_bool_array_pop(BoolArray *array); +b32 *wapp_b32_array_get(const B32Array *array, u64 index); +void wapp_b32_array_set(B32Array *array, u64 index, b32 *item); +void wapp_b32_array_append_capped(B32Array *array, b32 *item); +void wapp_b32_array_extend_capped(B32Array *array, const B32Array *other); +void wapp_b32_array_clear(B32Array *array); +void wapp_b32_array_copy_capped(const B32Array *src, B32Array *dst); +B32Array *wapp_b32_array_append_alloc(const Allocator *allocator, B32Array *array, b32 *item); +B32Array *wapp_b32_array_extend_alloc(const Allocator *allocator, B32Array *array, const B32Array *other); +B32Array *wapp_b32_array_copy_alloc(const Allocator *allocator, const B32Array *src, B32Array *dst); +b32 *_b32_array_pop(B32Array *array); char *wapp_char_array_get(const CharArray *array, u64 index); void wapp_char_array_set(CharArray *array, u64 index, char *item); void wapp_char_array_append_capped(CharArray *array, char *item); diff --git a/src/primitives/dbl_list/dbl_list.c b/src/primitives/dbl_list/dbl_list.c index f5ebc96..9578b7f 100644 --- a/src/primitives/dbl_list/dbl_list.c +++ b/src/primitives/dbl_list/dbl_list.c @@ -5,14 +5,14 @@ #include "./dbl_list.h" #include "../../common/assert/assert.h" #include "../../common/aliases/aliases.h" +#include "../../common/aliases/aliases.h" #include "../../common/platform/platform.h" #include #include -#include internal Str8List str8_node_to_list(Str8Node *node); internal VoidPList void_ptr_node_to_list(VoidPNode *node); -internal BoolList bool_node_to_list(BoolNode *node); +internal B32List b32_node_to_list(B32Node *node); internal CharList char_node_to_list(CharNode *node); internal C8List c8_node_to_list(C8Node *node); internal C16List c16_node_to_list(C16Node *node); @@ -32,7 +32,7 @@ internal IptrList iptr_node_to_list(IptrNode *node); internal UptrList uptr_node_to_list(UptrNode *node); Str8Node *wapp_str8_list_get(const Str8List *list, u64 index) { - assert(index < list->node_count); + wapp_runtime_assert(index < list->node_count, "`index` is out of bounds"); Str8Node *output = NULL; Str8Node *current = list->first; @@ -46,7 +46,7 @@ Str8Node *wapp_str8_list_get(const Str8List *list, u64 index) { } void wapp_str8_list_push_front(Str8List *list, Str8Node *node) { - assert(list != NULL && node != NULL && (node->item) != NULL); + wapp_debug_assert(list != NULL && node != NULL && (node->item) != NULL, "`list`, `node` and `node->item` should not be NULL"); Str8List node_list = str8_node_to_list(node); @@ -67,7 +67,7 @@ void wapp_str8_list_push_front(Str8List *list, Str8Node *node) { } void wapp_str8_list_push_back(Str8List *list, Str8Node *node) { - assert(list != NULL && node != NULL && (node->item) != NULL); + wapp_debug_assert(list != NULL && node != NULL && (node->item) != NULL, "`list`, `node` and `node->item` should not be NULL"); Str8List node_list = str8_node_to_list(node); @@ -88,7 +88,7 @@ void wapp_str8_list_push_back(Str8List *list, Str8Node *node) { } void wapp_str8_list_insert(Str8List *list, Str8Node *node, u64 index) { - assert(list != NULL && node != NULL && (node->item) != NULL); + wapp_debug_assert(list != NULL && node != NULL && (node->item) != NULL, "`list`, `node` and `node->item` should not be NULL"); if (index == 0) { wapp_str8_list_push_front(list, node); @@ -117,7 +117,7 @@ void wapp_str8_list_insert(Str8List *list, Str8Node *node, u64 index) { } Str8Node *wapp_str8_list_pop_front(Str8List *list) { - assert(list != NULL); + wapp_debug_assert(list != NULL, "`list` should not be NULL"); Str8Node *output = NULL; @@ -142,7 +142,7 @@ RETURN_STR8_LIST_POP_FRONT: } Str8Node *wapp_str8_list_pop_back(Str8List *list) { - assert(list != NULL); + wapp_debug_assert(list != NULL, "`list` should not be NULL"); Str8Node *output = NULL; @@ -167,7 +167,7 @@ RETURN_STR8_LIST_POP_BACK: } Str8Node *wapp_str8_list_remove(Str8List *list, u64 index) { - assert(list != NULL); + wapp_debug_assert(list != NULL, "`list` should not be NULL"); Str8Node *output = NULL; @@ -196,7 +196,7 @@ RETURN_STR8_LIST_REMOVE: } void wapp_str8_list_empty(Str8List *list) { - assert(list != NULL); + wapp_debug_assert(list != NULL, "`list` should not be NULL"); u64 count = list->node_count; for (u64 i = 0; i < count; ++i) { @@ -205,7 +205,7 @@ void wapp_str8_list_empty(Str8List *list) { } VoidPNode *wapp_void_ptr_list_get(const VoidPList *list, u64 index) { - assert(index < list->node_count); + wapp_runtime_assert(index < list->node_count, "`index` is out of bounds"); VoidPNode *output = NULL; VoidPNode *current = list->first; @@ -219,7 +219,7 @@ VoidPNode *wapp_void_ptr_list_get(const VoidPList *list, u64 index) { } void wapp_void_ptr_list_push_front(VoidPList *list, VoidPNode *node) { - assert(list != NULL && node != NULL && (node->item) != NULL); + wapp_debug_assert(list != NULL && node != NULL && (node->item) != NULL, "`list`, `node` and `node->item` should not be NULL"); VoidPList node_list = void_ptr_node_to_list(node); @@ -240,7 +240,7 @@ void wapp_void_ptr_list_push_front(VoidPList *list, VoidPNode *node) { } void wapp_void_ptr_list_push_back(VoidPList *list, VoidPNode *node) { - assert(list != NULL && node != NULL && (node->item) != NULL); + wapp_debug_assert(list != NULL && node != NULL && (node->item) != NULL, "`list`, `node` and `node->item` should not be NULL"); VoidPList node_list = void_ptr_node_to_list(node); @@ -261,7 +261,7 @@ void wapp_void_ptr_list_push_back(VoidPList *list, VoidPNode *node) { } void wapp_void_ptr_list_insert(VoidPList *list, VoidPNode *node, u64 index) { - assert(list != NULL && node != NULL && (node->item) != NULL); + wapp_debug_assert(list != NULL && node != NULL && (node->item) != NULL, "`list`, `node` and `node->item` should not be NULL"); if (index == 0) { wapp_void_ptr_list_push_front(list, node); @@ -290,7 +290,7 @@ void wapp_void_ptr_list_insert(VoidPList *list, VoidPNode *node, u64 index) { } VoidPNode *wapp_void_ptr_list_pop_front(VoidPList *list) { - assert(list != NULL); + wapp_debug_assert(list != NULL, "`list` should not be NULL"); VoidPNode *output = NULL; @@ -315,7 +315,7 @@ RETURN_VOID_PTR_LIST_POP_FRONT: } VoidPNode *wapp_void_ptr_list_pop_back(VoidPList *list) { - assert(list != NULL); + wapp_debug_assert(list != NULL, "`list` should not be NULL"); VoidPNode *output = NULL; @@ -340,7 +340,7 @@ RETURN_VOID_PTR_LIST_POP_BACK: } VoidPNode *wapp_void_ptr_list_remove(VoidPList *list, u64 index) { - assert(list != NULL); + wapp_debug_assert(list != NULL, "`list` should not be NULL"); VoidPNode *output = NULL; @@ -369,7 +369,7 @@ RETURN_VOID_PTR_LIST_REMOVE: } void wapp_void_ptr_list_empty(VoidPList *list) { - assert(list != NULL); + wapp_debug_assert(list != NULL, "`list` should not be NULL"); u64 count = list->node_count; for (u64 i = 0; i < count; ++i) { @@ -377,11 +377,11 @@ void wapp_void_ptr_list_empty(VoidPList *list) { } } -BoolNode *wapp_bool_list_get(const BoolList *list, u64 index) { - assert(index < list->node_count); +B32Node *wapp_b32_list_get(const B32List *list, u64 index) { + wapp_runtime_assert(index < list->node_count, "`index` is out of bounds"); - BoolNode *output = NULL; - BoolNode *current = list->first; + B32Node *output = NULL; + B32Node *current = list->first; for (u64 i = 1; i <= index; ++i) { current = current->next; } @@ -391,10 +391,10 @@ BoolNode *wapp_bool_list_get(const BoolList *list, u64 index) { return output; } -void wapp_bool_list_push_front(BoolList *list, BoolNode *node) { - assert(list != NULL && node != NULL && (node->item) != NULL); +void wapp_b32_list_push_front(B32List *list, B32Node *node) { + wapp_debug_assert(list != NULL && node != NULL && (node->item) != NULL, "`list`, `node` and `node->item` should not be NULL"); - BoolList node_list = bool_node_to_list(node); + B32List node_list = b32_node_to_list(node); if (list->node_count == 0) { *list = node_list; @@ -403,7 +403,7 @@ void wapp_bool_list_push_front(BoolList *list, BoolNode *node) { list->node_count += node_list.node_count; - BoolNode *first = list->first; + B32Node *first = list->first; if (first) { first->prev = node_list.last; } @@ -412,10 +412,10 @@ void wapp_bool_list_push_front(BoolList *list, BoolNode *node) { node_list.last->next = first; } -void wapp_bool_list_push_back(BoolList *list, BoolNode *node) { - assert(list != NULL && node != NULL && (node->item) != NULL); +void wapp_b32_list_push_back(B32List *list, B32Node *node) { + wapp_debug_assert(list != NULL && node != NULL && (node->item) != NULL, "`list`, `node` and `node->item` should not be NULL"); - BoolList node_list = bool_node_to_list(node); + B32List node_list = b32_node_to_list(node); if (list->node_count == 0) { *list = node_list; @@ -424,7 +424,7 @@ void wapp_bool_list_push_back(BoolList *list, BoolNode *node) { list->node_count += node_list.node_count; - BoolNode *last = list->last; + B32Node *last = list->last; if (last) { last->next = node_list.first; } @@ -433,27 +433,27 @@ void wapp_bool_list_push_back(BoolList *list, BoolNode *node) { node_list.first->prev = last; } -void wapp_bool_list_insert(BoolList *list, BoolNode *node, u64 index) { - assert(list != NULL && node != NULL && (node->item) != NULL); +void wapp_b32_list_insert(B32List *list, B32Node *node, u64 index) { + wapp_debug_assert(list != NULL && node != NULL && (node->item) != NULL, "`list`, `node` and `node->item` should not be NULL"); if (index == 0) { - wapp_bool_list_push_front(list, node); + wapp_b32_list_push_front(list, node); return; } else if (index == list->node_count) { - wapp_bool_list_push_back(list, node); + wapp_b32_list_push_back(list, node); return; } - BoolNode *dst_node = wapp_bool_list_get(list, index); + B32Node *dst_node = wapp_b32_list_get(list, index); if (!dst_node) { return; } - BoolList node_list = bool_node_to_list(node); + B32List node_list = b32_node_to_list(node); list->node_count += node_list.node_count; - BoolNode *prev = dst_node->prev; + B32Node *prev = dst_node->prev; dst_node->prev = node_list.last; prev->next = node_list.first; @@ -462,20 +462,20 @@ void wapp_bool_list_insert(BoolList *list, BoolNode *node, u64 index) { node_list.last->next = dst_node; } -BoolNode *wapp_bool_list_pop_front(BoolList *list) { - assert(list != NULL); +B32Node *wapp_b32_list_pop_front(B32List *list) { + wapp_debug_assert(list != NULL, "`list` should not be NULL"); - BoolNode *output = NULL; + B32Node *output = NULL; if (list->node_count == 0) { - goto RETURN_BOOL_LIST_POP_FRONT; + goto RETURN_B32_LIST_POP_FRONT; } output = list->first; if (list->node_count == 1) { - *list = (BoolList){0}; - goto RETURN_BOOL_LIST_POP_FRONT; + *list = (B32List){0}; + goto RETURN_B32_LIST_POP_FRONT; } --(list->node_count); @@ -483,24 +483,24 @@ BoolNode *wapp_bool_list_pop_front(BoolList *list) { output->prev = output->next = NULL; -RETURN_BOOL_LIST_POP_FRONT: +RETURN_B32_LIST_POP_FRONT: return output; } -BoolNode *wapp_bool_list_pop_back(BoolList *list) { - assert(list != NULL); +B32Node *wapp_b32_list_pop_back(B32List *list) { + wapp_debug_assert(list != NULL, "`list` should not be NULL"); - BoolNode *output = NULL; + B32Node *output = NULL; if (list->node_count == 0) { - goto RETURN_BOOL_LIST_POP_BACK; + goto RETURN_B32_LIST_POP_BACK; } output = list->last; if (list->node_count == 1) { - *list = (BoolList){0}; - goto RETURN_BOOL_LIST_POP_BACK; + *list = (B32List){0}; + goto RETURN_B32_LIST_POP_BACK; } --(list->node_count); @@ -508,26 +508,26 @@ BoolNode *wapp_bool_list_pop_back(BoolList *list) { output->prev = output->next = NULL; -RETURN_BOOL_LIST_POP_BACK: +RETURN_B32_LIST_POP_BACK: return output; } -BoolNode *wapp_bool_list_remove(BoolList *list, u64 index) { - assert(list != NULL); +B32Node *wapp_b32_list_remove(B32List *list, u64 index) { + wapp_debug_assert(list != NULL, "`list` should not be NULL"); - BoolNode *output = NULL; + B32Node *output = NULL; if (index == 0) { - output = wapp_bool_list_pop_front(list); - goto RETURN_BOOL_LIST_REMOVE; + output = wapp_b32_list_pop_front(list); + goto RETURN_B32_LIST_REMOVE; } else if (index == list->node_count) { - output = wapp_bool_list_pop_back(list); - goto RETURN_BOOL_LIST_REMOVE; + output = wapp_b32_list_pop_back(list); + goto RETURN_B32_LIST_REMOVE; } - output = wapp_bool_list_get(list, index); + output = wapp_b32_list_get(list, index); if (!output) { - goto RETURN_BOOL_LIST_REMOVE; + goto RETURN_B32_LIST_REMOVE; } output->prev->next = output->next; @@ -537,21 +537,21 @@ BoolNode *wapp_bool_list_remove(BoolList *list, u64 index) { output->prev = output->next = NULL; -RETURN_BOOL_LIST_REMOVE: +RETURN_B32_LIST_REMOVE: return output; } -void wapp_bool_list_empty(BoolList *list) { - assert(list != NULL); +void wapp_b32_list_empty(B32List *list) { + wapp_debug_assert(list != NULL, "`list` should not be NULL"); u64 count = list->node_count; for (u64 i = 0; i < count; ++i) { - wapp_bool_list_pop_back(list); + wapp_b32_list_pop_back(list); } } CharNode *wapp_char_list_get(const CharList *list, u64 index) { - assert(index < list->node_count); + wapp_runtime_assert(index < list->node_count, "`index` is out of bounds"); CharNode *output = NULL; CharNode *current = list->first; @@ -565,7 +565,7 @@ CharNode *wapp_char_list_get(const CharList *list, u64 index) { } void wapp_char_list_push_front(CharList *list, CharNode *node) { - assert(list != NULL && node != NULL && (node->item) != NULL); + wapp_debug_assert(list != NULL && node != NULL && (node->item) != NULL, "`list`, `node` and `node->item` should not be NULL"); CharList node_list = char_node_to_list(node); @@ -586,7 +586,7 @@ void wapp_char_list_push_front(CharList *list, CharNode *node) { } void wapp_char_list_push_back(CharList *list, CharNode *node) { - assert(list != NULL && node != NULL && (node->item) != NULL); + wapp_debug_assert(list != NULL && node != NULL && (node->item) != NULL, "`list`, `node` and `node->item` should not be NULL"); CharList node_list = char_node_to_list(node); @@ -607,7 +607,7 @@ void wapp_char_list_push_back(CharList *list, CharNode *node) { } void wapp_char_list_insert(CharList *list, CharNode *node, u64 index) { - assert(list != NULL && node != NULL && (node->item) != NULL); + wapp_debug_assert(list != NULL && node != NULL && (node->item) != NULL, "`list`, `node` and `node->item` should not be NULL"); if (index == 0) { wapp_char_list_push_front(list, node); @@ -636,7 +636,7 @@ void wapp_char_list_insert(CharList *list, CharNode *node, u64 index) { } CharNode *wapp_char_list_pop_front(CharList *list) { - assert(list != NULL); + wapp_debug_assert(list != NULL, "`list` should not be NULL"); CharNode *output = NULL; @@ -661,7 +661,7 @@ RETURN_CHAR_LIST_POP_FRONT: } CharNode *wapp_char_list_pop_back(CharList *list) { - assert(list != NULL); + wapp_debug_assert(list != NULL, "`list` should not be NULL"); CharNode *output = NULL; @@ -686,7 +686,7 @@ RETURN_CHAR_LIST_POP_BACK: } CharNode *wapp_char_list_remove(CharList *list, u64 index) { - assert(list != NULL); + wapp_debug_assert(list != NULL, "`list` should not be NULL"); CharNode *output = NULL; @@ -715,7 +715,7 @@ RETURN_CHAR_LIST_REMOVE: } void wapp_char_list_empty(CharList *list) { - assert(list != NULL); + wapp_debug_assert(list != NULL, "`list` should not be NULL"); u64 count = list->node_count; for (u64 i = 0; i < count; ++i) { @@ -724,7 +724,7 @@ void wapp_char_list_empty(CharList *list) { } C8Node *wapp_c8_list_get(const C8List *list, u64 index) { - assert(index < list->node_count); + wapp_runtime_assert(index < list->node_count, "`index` is out of bounds"); C8Node *output = NULL; C8Node *current = list->first; @@ -738,7 +738,7 @@ C8Node *wapp_c8_list_get(const C8List *list, u64 index) { } void wapp_c8_list_push_front(C8List *list, C8Node *node) { - assert(list != NULL && node != NULL && (node->item) != NULL); + wapp_debug_assert(list != NULL && node != NULL && (node->item) != NULL, "`list`, `node` and `node->item` should not be NULL"); C8List node_list = c8_node_to_list(node); @@ -759,7 +759,7 @@ void wapp_c8_list_push_front(C8List *list, C8Node *node) { } void wapp_c8_list_push_back(C8List *list, C8Node *node) { - assert(list != NULL && node != NULL && (node->item) != NULL); + wapp_debug_assert(list != NULL && node != NULL && (node->item) != NULL, "`list`, `node` and `node->item` should not be NULL"); C8List node_list = c8_node_to_list(node); @@ -780,7 +780,7 @@ void wapp_c8_list_push_back(C8List *list, C8Node *node) { } void wapp_c8_list_insert(C8List *list, C8Node *node, u64 index) { - assert(list != NULL && node != NULL && (node->item) != NULL); + wapp_debug_assert(list != NULL && node != NULL && (node->item) != NULL, "`list`, `node` and `node->item` should not be NULL"); if (index == 0) { wapp_c8_list_push_front(list, node); @@ -809,7 +809,7 @@ void wapp_c8_list_insert(C8List *list, C8Node *node, u64 index) { } C8Node *wapp_c8_list_pop_front(C8List *list) { - assert(list != NULL); + wapp_debug_assert(list != NULL, "`list` should not be NULL"); C8Node *output = NULL; @@ -834,7 +834,7 @@ RETURN_C8_LIST_POP_FRONT: } C8Node *wapp_c8_list_pop_back(C8List *list) { - assert(list != NULL); + wapp_debug_assert(list != NULL, "`list` should not be NULL"); C8Node *output = NULL; @@ -859,7 +859,7 @@ RETURN_C8_LIST_POP_BACK: } C8Node *wapp_c8_list_remove(C8List *list, u64 index) { - assert(list != NULL); + wapp_debug_assert(list != NULL, "`list` should not be NULL"); C8Node *output = NULL; @@ -888,7 +888,7 @@ RETURN_C8_LIST_REMOVE: } void wapp_c8_list_empty(C8List *list) { - assert(list != NULL); + wapp_debug_assert(list != NULL, "`list` should not be NULL"); u64 count = list->node_count; for (u64 i = 0; i < count; ++i) { @@ -897,7 +897,7 @@ void wapp_c8_list_empty(C8List *list) { } C16Node *wapp_c16_list_get(const C16List *list, u64 index) { - assert(index < list->node_count); + wapp_runtime_assert(index < list->node_count, "`index` is out of bounds"); C16Node *output = NULL; C16Node *current = list->first; @@ -911,7 +911,7 @@ C16Node *wapp_c16_list_get(const C16List *list, u64 index) { } void wapp_c16_list_push_front(C16List *list, C16Node *node) { - assert(list != NULL && node != NULL && (node->item) != NULL); + wapp_debug_assert(list != NULL && node != NULL && (node->item) != NULL, "`list`, `node` and `node->item` should not be NULL"); C16List node_list = c16_node_to_list(node); @@ -932,7 +932,7 @@ void wapp_c16_list_push_front(C16List *list, C16Node *node) { } void wapp_c16_list_push_back(C16List *list, C16Node *node) { - assert(list != NULL && node != NULL && (node->item) != NULL); + wapp_debug_assert(list != NULL && node != NULL && (node->item) != NULL, "`list`, `node` and `node->item` should not be NULL"); C16List node_list = c16_node_to_list(node); @@ -953,7 +953,7 @@ void wapp_c16_list_push_back(C16List *list, C16Node *node) { } void wapp_c16_list_insert(C16List *list, C16Node *node, u64 index) { - assert(list != NULL && node != NULL && (node->item) != NULL); + wapp_debug_assert(list != NULL && node != NULL && (node->item) != NULL, "`list`, `node` and `node->item` should not be NULL"); if (index == 0) { wapp_c16_list_push_front(list, node); @@ -982,7 +982,7 @@ void wapp_c16_list_insert(C16List *list, C16Node *node, u64 index) { } C16Node *wapp_c16_list_pop_front(C16List *list) { - assert(list != NULL); + wapp_debug_assert(list != NULL, "`list` should not be NULL"); C16Node *output = NULL; @@ -1007,7 +1007,7 @@ RETURN_C16_LIST_POP_FRONT: } C16Node *wapp_c16_list_pop_back(C16List *list) { - assert(list != NULL); + wapp_debug_assert(list != NULL, "`list` should not be NULL"); C16Node *output = NULL; @@ -1032,7 +1032,7 @@ RETURN_C16_LIST_POP_BACK: } C16Node *wapp_c16_list_remove(C16List *list, u64 index) { - assert(list != NULL); + wapp_debug_assert(list != NULL, "`list` should not be NULL"); C16Node *output = NULL; @@ -1061,7 +1061,7 @@ RETURN_C16_LIST_REMOVE: } void wapp_c16_list_empty(C16List *list) { - assert(list != NULL); + wapp_debug_assert(list != NULL, "`list` should not be NULL"); u64 count = list->node_count; for (u64 i = 0; i < count; ++i) { @@ -1070,7 +1070,7 @@ void wapp_c16_list_empty(C16List *list) { } C32Node *wapp_c32_list_get(const C32List *list, u64 index) { - assert(index < list->node_count); + wapp_runtime_assert(index < list->node_count, "`index` is out of bounds"); C32Node *output = NULL; C32Node *current = list->first; @@ -1084,7 +1084,7 @@ C32Node *wapp_c32_list_get(const C32List *list, u64 index) { } void wapp_c32_list_push_front(C32List *list, C32Node *node) { - assert(list != NULL && node != NULL && (node->item) != NULL); + wapp_debug_assert(list != NULL && node != NULL && (node->item) != NULL, "`list`, `node` and `node->item` should not be NULL"); C32List node_list = c32_node_to_list(node); @@ -1105,7 +1105,7 @@ void wapp_c32_list_push_front(C32List *list, C32Node *node) { } void wapp_c32_list_push_back(C32List *list, C32Node *node) { - assert(list != NULL && node != NULL && (node->item) != NULL); + wapp_debug_assert(list != NULL && node != NULL && (node->item) != NULL, "`list`, `node` and `node->item` should not be NULL"); C32List node_list = c32_node_to_list(node); @@ -1126,7 +1126,7 @@ void wapp_c32_list_push_back(C32List *list, C32Node *node) { } void wapp_c32_list_insert(C32List *list, C32Node *node, u64 index) { - assert(list != NULL && node != NULL && (node->item) != NULL); + wapp_debug_assert(list != NULL && node != NULL && (node->item) != NULL, "`list`, `node` and `node->item` should not be NULL"); if (index == 0) { wapp_c32_list_push_front(list, node); @@ -1155,7 +1155,7 @@ void wapp_c32_list_insert(C32List *list, C32Node *node, u64 index) { } C32Node *wapp_c32_list_pop_front(C32List *list) { - assert(list != NULL); + wapp_debug_assert(list != NULL, "`list` should not be NULL"); C32Node *output = NULL; @@ -1180,7 +1180,7 @@ RETURN_C32_LIST_POP_FRONT: } C32Node *wapp_c32_list_pop_back(C32List *list) { - assert(list != NULL); + wapp_debug_assert(list != NULL, "`list` should not be NULL"); C32Node *output = NULL; @@ -1205,7 +1205,7 @@ RETURN_C32_LIST_POP_BACK: } C32Node *wapp_c32_list_remove(C32List *list, u64 index) { - assert(list != NULL); + wapp_debug_assert(list != NULL, "`list` should not be NULL"); C32Node *output = NULL; @@ -1234,7 +1234,7 @@ RETURN_C32_LIST_REMOVE: } void wapp_c32_list_empty(C32List *list) { - assert(list != NULL); + wapp_debug_assert(list != NULL, "`list` should not be NULL"); u64 count = list->node_count; for (u64 i = 0; i < count; ++i) { @@ -1243,7 +1243,7 @@ void wapp_c32_list_empty(C32List *list) { } I8Node *wapp_i8_list_get(const I8List *list, u64 index) { - assert(index < list->node_count); + wapp_runtime_assert(index < list->node_count, "`index` is out of bounds"); I8Node *output = NULL; I8Node *current = list->first; @@ -1257,7 +1257,7 @@ I8Node *wapp_i8_list_get(const I8List *list, u64 index) { } void wapp_i8_list_push_front(I8List *list, I8Node *node) { - assert(list != NULL && node != NULL && (node->item) != NULL); + wapp_debug_assert(list != NULL && node != NULL && (node->item) != NULL, "`list`, `node` and `node->item` should not be NULL"); I8List node_list = i8_node_to_list(node); @@ -1278,7 +1278,7 @@ void wapp_i8_list_push_front(I8List *list, I8Node *node) { } void wapp_i8_list_push_back(I8List *list, I8Node *node) { - assert(list != NULL && node != NULL && (node->item) != NULL); + wapp_debug_assert(list != NULL && node != NULL && (node->item) != NULL, "`list`, `node` and `node->item` should not be NULL"); I8List node_list = i8_node_to_list(node); @@ -1299,7 +1299,7 @@ void wapp_i8_list_push_back(I8List *list, I8Node *node) { } void wapp_i8_list_insert(I8List *list, I8Node *node, u64 index) { - assert(list != NULL && node != NULL && (node->item) != NULL); + wapp_debug_assert(list != NULL && node != NULL && (node->item) != NULL, "`list`, `node` and `node->item` should not be NULL"); if (index == 0) { wapp_i8_list_push_front(list, node); @@ -1328,7 +1328,7 @@ void wapp_i8_list_insert(I8List *list, I8Node *node, u64 index) { } I8Node *wapp_i8_list_pop_front(I8List *list) { - assert(list != NULL); + wapp_debug_assert(list != NULL, "`list` should not be NULL"); I8Node *output = NULL; @@ -1353,7 +1353,7 @@ RETURN_I8_LIST_POP_FRONT: } I8Node *wapp_i8_list_pop_back(I8List *list) { - assert(list != NULL); + wapp_debug_assert(list != NULL, "`list` should not be NULL"); I8Node *output = NULL; @@ -1378,7 +1378,7 @@ RETURN_I8_LIST_POP_BACK: } I8Node *wapp_i8_list_remove(I8List *list, u64 index) { - assert(list != NULL); + wapp_debug_assert(list != NULL, "`list` should not be NULL"); I8Node *output = NULL; @@ -1407,7 +1407,7 @@ RETURN_I8_LIST_REMOVE: } void wapp_i8_list_empty(I8List *list) { - assert(list != NULL); + wapp_debug_assert(list != NULL, "`list` should not be NULL"); u64 count = list->node_count; for (u64 i = 0; i < count; ++i) { @@ -1416,7 +1416,7 @@ void wapp_i8_list_empty(I8List *list) { } I16Node *wapp_i16_list_get(const I16List *list, u64 index) { - assert(index < list->node_count); + wapp_runtime_assert(index < list->node_count, "`index` is out of bounds"); I16Node *output = NULL; I16Node *current = list->first; @@ -1430,7 +1430,7 @@ I16Node *wapp_i16_list_get(const I16List *list, u64 index) { } void wapp_i16_list_push_front(I16List *list, I16Node *node) { - assert(list != NULL && node != NULL && (node->item) != NULL); + wapp_debug_assert(list != NULL && node != NULL && (node->item) != NULL, "`list`, `node` and `node->item` should not be NULL"); I16List node_list = i16_node_to_list(node); @@ -1451,7 +1451,7 @@ void wapp_i16_list_push_front(I16List *list, I16Node *node) { } void wapp_i16_list_push_back(I16List *list, I16Node *node) { - assert(list != NULL && node != NULL && (node->item) != NULL); + wapp_debug_assert(list != NULL && node != NULL && (node->item) != NULL, "`list`, `node` and `node->item` should not be NULL"); I16List node_list = i16_node_to_list(node); @@ -1472,7 +1472,7 @@ void wapp_i16_list_push_back(I16List *list, I16Node *node) { } void wapp_i16_list_insert(I16List *list, I16Node *node, u64 index) { - assert(list != NULL && node != NULL && (node->item) != NULL); + wapp_debug_assert(list != NULL && node != NULL && (node->item) != NULL, "`list`, `node` and `node->item` should not be NULL"); if (index == 0) { wapp_i16_list_push_front(list, node); @@ -1501,7 +1501,7 @@ void wapp_i16_list_insert(I16List *list, I16Node *node, u64 index) { } I16Node *wapp_i16_list_pop_front(I16List *list) { - assert(list != NULL); + wapp_debug_assert(list != NULL, "`list` should not be NULL"); I16Node *output = NULL; @@ -1526,7 +1526,7 @@ RETURN_I16_LIST_POP_FRONT: } I16Node *wapp_i16_list_pop_back(I16List *list) { - assert(list != NULL); + wapp_debug_assert(list != NULL, "`list` should not be NULL"); I16Node *output = NULL; @@ -1551,7 +1551,7 @@ RETURN_I16_LIST_POP_BACK: } I16Node *wapp_i16_list_remove(I16List *list, u64 index) { - assert(list != NULL); + wapp_debug_assert(list != NULL, "`list` should not be NULL"); I16Node *output = NULL; @@ -1580,7 +1580,7 @@ RETURN_I16_LIST_REMOVE: } void wapp_i16_list_empty(I16List *list) { - assert(list != NULL); + wapp_debug_assert(list != NULL, "`list` should not be NULL"); u64 count = list->node_count; for (u64 i = 0; i < count; ++i) { @@ -1589,7 +1589,7 @@ void wapp_i16_list_empty(I16List *list) { } I32Node *wapp_i32_list_get(const I32List *list, u64 index) { - assert(index < list->node_count); + wapp_runtime_assert(index < list->node_count, "`index` is out of bounds"); I32Node *output = NULL; I32Node *current = list->first; @@ -1603,7 +1603,7 @@ I32Node *wapp_i32_list_get(const I32List *list, u64 index) { } void wapp_i32_list_push_front(I32List *list, I32Node *node) { - assert(list != NULL && node != NULL && (node->item) != NULL); + wapp_debug_assert(list != NULL && node != NULL && (node->item) != NULL, "`list`, `node` and `node->item` should not be NULL"); I32List node_list = i32_node_to_list(node); @@ -1624,7 +1624,7 @@ void wapp_i32_list_push_front(I32List *list, I32Node *node) { } void wapp_i32_list_push_back(I32List *list, I32Node *node) { - assert(list != NULL && node != NULL && (node->item) != NULL); + wapp_debug_assert(list != NULL && node != NULL && (node->item) != NULL, "`list`, `node` and `node->item` should not be NULL"); I32List node_list = i32_node_to_list(node); @@ -1645,7 +1645,7 @@ void wapp_i32_list_push_back(I32List *list, I32Node *node) { } void wapp_i32_list_insert(I32List *list, I32Node *node, u64 index) { - assert(list != NULL && node != NULL && (node->item) != NULL); + wapp_debug_assert(list != NULL && node != NULL && (node->item) != NULL, "`list`, `node` and `node->item` should not be NULL"); if (index == 0) { wapp_i32_list_push_front(list, node); @@ -1674,7 +1674,7 @@ void wapp_i32_list_insert(I32List *list, I32Node *node, u64 index) { } I32Node *wapp_i32_list_pop_front(I32List *list) { - assert(list != NULL); + wapp_debug_assert(list != NULL, "`list` should not be NULL"); I32Node *output = NULL; @@ -1699,7 +1699,7 @@ RETURN_I32_LIST_POP_FRONT: } I32Node *wapp_i32_list_pop_back(I32List *list) { - assert(list != NULL); + wapp_debug_assert(list != NULL, "`list` should not be NULL"); I32Node *output = NULL; @@ -1724,7 +1724,7 @@ RETURN_I32_LIST_POP_BACK: } I32Node *wapp_i32_list_remove(I32List *list, u64 index) { - assert(list != NULL); + wapp_debug_assert(list != NULL, "`list` should not be NULL"); I32Node *output = NULL; @@ -1753,7 +1753,7 @@ RETURN_I32_LIST_REMOVE: } void wapp_i32_list_empty(I32List *list) { - assert(list != NULL); + wapp_debug_assert(list != NULL, "`list` should not be NULL"); u64 count = list->node_count; for (u64 i = 0; i < count; ++i) { @@ -1762,7 +1762,7 @@ void wapp_i32_list_empty(I32List *list) { } I64Node *wapp_i64_list_get(const I64List *list, u64 index) { - assert(index < list->node_count); + wapp_runtime_assert(index < list->node_count, "`index` is out of bounds"); I64Node *output = NULL; I64Node *current = list->first; @@ -1776,7 +1776,7 @@ I64Node *wapp_i64_list_get(const I64List *list, u64 index) { } void wapp_i64_list_push_front(I64List *list, I64Node *node) { - assert(list != NULL && node != NULL && (node->item) != NULL); + wapp_debug_assert(list != NULL && node != NULL && (node->item) != NULL, "`list`, `node` and `node->item` should not be NULL"); I64List node_list = i64_node_to_list(node); @@ -1797,7 +1797,7 @@ void wapp_i64_list_push_front(I64List *list, I64Node *node) { } void wapp_i64_list_push_back(I64List *list, I64Node *node) { - assert(list != NULL && node != NULL && (node->item) != NULL); + wapp_debug_assert(list != NULL && node != NULL && (node->item) != NULL, "`list`, `node` and `node->item` should not be NULL"); I64List node_list = i64_node_to_list(node); @@ -1818,7 +1818,7 @@ void wapp_i64_list_push_back(I64List *list, I64Node *node) { } void wapp_i64_list_insert(I64List *list, I64Node *node, u64 index) { - assert(list != NULL && node != NULL && (node->item) != NULL); + wapp_debug_assert(list != NULL && node != NULL && (node->item) != NULL, "`list`, `node` and `node->item` should not be NULL"); if (index == 0) { wapp_i64_list_push_front(list, node); @@ -1847,7 +1847,7 @@ void wapp_i64_list_insert(I64List *list, I64Node *node, u64 index) { } I64Node *wapp_i64_list_pop_front(I64List *list) { - assert(list != NULL); + wapp_debug_assert(list != NULL, "`list` should not be NULL"); I64Node *output = NULL; @@ -1872,7 +1872,7 @@ RETURN_I64_LIST_POP_FRONT: } I64Node *wapp_i64_list_pop_back(I64List *list) { - assert(list != NULL); + wapp_debug_assert(list != NULL, "`list` should not be NULL"); I64Node *output = NULL; @@ -1897,7 +1897,7 @@ RETURN_I64_LIST_POP_BACK: } I64Node *wapp_i64_list_remove(I64List *list, u64 index) { - assert(list != NULL); + wapp_debug_assert(list != NULL, "`list` should not be NULL"); I64Node *output = NULL; @@ -1926,7 +1926,7 @@ RETURN_I64_LIST_REMOVE: } void wapp_i64_list_empty(I64List *list) { - assert(list != NULL); + wapp_debug_assert(list != NULL, "`list` should not be NULL"); u64 count = list->node_count; for (u64 i = 0; i < count; ++i) { @@ -1935,7 +1935,7 @@ void wapp_i64_list_empty(I64List *list) { } U8Node *wapp_u8_list_get(const U8List *list, u64 index) { - assert(index < list->node_count); + wapp_runtime_assert(index < list->node_count, "`index` is out of bounds"); U8Node *output = NULL; U8Node *current = list->first; @@ -1949,7 +1949,7 @@ U8Node *wapp_u8_list_get(const U8List *list, u64 index) { } void wapp_u8_list_push_front(U8List *list, U8Node *node) { - assert(list != NULL && node != NULL && (node->item) != NULL); + wapp_debug_assert(list != NULL && node != NULL && (node->item) != NULL, "`list`, `node` and `node->item` should not be NULL"); U8List node_list = u8_node_to_list(node); @@ -1970,7 +1970,7 @@ void wapp_u8_list_push_front(U8List *list, U8Node *node) { } void wapp_u8_list_push_back(U8List *list, U8Node *node) { - assert(list != NULL && node != NULL && (node->item) != NULL); + wapp_debug_assert(list != NULL && node != NULL && (node->item) != NULL, "`list`, `node` and `node->item` should not be NULL"); U8List node_list = u8_node_to_list(node); @@ -1991,7 +1991,7 @@ void wapp_u8_list_push_back(U8List *list, U8Node *node) { } void wapp_u8_list_insert(U8List *list, U8Node *node, u64 index) { - assert(list != NULL && node != NULL && (node->item) != NULL); + wapp_debug_assert(list != NULL && node != NULL && (node->item) != NULL, "`list`, `node` and `node->item` should not be NULL"); if (index == 0) { wapp_u8_list_push_front(list, node); @@ -2020,7 +2020,7 @@ void wapp_u8_list_insert(U8List *list, U8Node *node, u64 index) { } U8Node *wapp_u8_list_pop_front(U8List *list) { - assert(list != NULL); + wapp_debug_assert(list != NULL, "`list` should not be NULL"); U8Node *output = NULL; @@ -2045,7 +2045,7 @@ RETURN_U8_LIST_POP_FRONT: } U8Node *wapp_u8_list_pop_back(U8List *list) { - assert(list != NULL); + wapp_debug_assert(list != NULL, "`list` should not be NULL"); U8Node *output = NULL; @@ -2070,7 +2070,7 @@ RETURN_U8_LIST_POP_BACK: } U8Node *wapp_u8_list_remove(U8List *list, u64 index) { - assert(list != NULL); + wapp_debug_assert(list != NULL, "`list` should not be NULL"); U8Node *output = NULL; @@ -2099,7 +2099,7 @@ RETURN_U8_LIST_REMOVE: } void wapp_u8_list_empty(U8List *list) { - assert(list != NULL); + wapp_debug_assert(list != NULL, "`list` should not be NULL"); u64 count = list->node_count; for (u64 i = 0; i < count; ++i) { @@ -2108,7 +2108,7 @@ void wapp_u8_list_empty(U8List *list) { } U16Node *wapp_u16_list_get(const U16List *list, u64 index) { - assert(index < list->node_count); + wapp_runtime_assert(index < list->node_count, "`index` is out of bounds"); U16Node *output = NULL; U16Node *current = list->first; @@ -2122,7 +2122,7 @@ U16Node *wapp_u16_list_get(const U16List *list, u64 index) { } void wapp_u16_list_push_front(U16List *list, U16Node *node) { - assert(list != NULL && node != NULL && (node->item) != NULL); + wapp_debug_assert(list != NULL && node != NULL && (node->item) != NULL, "`list`, `node` and `node->item` should not be NULL"); U16List node_list = u16_node_to_list(node); @@ -2143,7 +2143,7 @@ void wapp_u16_list_push_front(U16List *list, U16Node *node) { } void wapp_u16_list_push_back(U16List *list, U16Node *node) { - assert(list != NULL && node != NULL && (node->item) != NULL); + wapp_debug_assert(list != NULL && node != NULL && (node->item) != NULL, "`list`, `node` and `node->item` should not be NULL"); U16List node_list = u16_node_to_list(node); @@ -2164,7 +2164,7 @@ void wapp_u16_list_push_back(U16List *list, U16Node *node) { } void wapp_u16_list_insert(U16List *list, U16Node *node, u64 index) { - assert(list != NULL && node != NULL && (node->item) != NULL); + wapp_debug_assert(list != NULL && node != NULL && (node->item) != NULL, "`list`, `node` and `node->item` should not be NULL"); if (index == 0) { wapp_u16_list_push_front(list, node); @@ -2193,7 +2193,7 @@ void wapp_u16_list_insert(U16List *list, U16Node *node, u64 index) { } U16Node *wapp_u16_list_pop_front(U16List *list) { - assert(list != NULL); + wapp_debug_assert(list != NULL, "`list` should not be NULL"); U16Node *output = NULL; @@ -2218,7 +2218,7 @@ RETURN_U16_LIST_POP_FRONT: } U16Node *wapp_u16_list_pop_back(U16List *list) { - assert(list != NULL); + wapp_debug_assert(list != NULL, "`list` should not be NULL"); U16Node *output = NULL; @@ -2243,7 +2243,7 @@ RETURN_U16_LIST_POP_BACK: } U16Node *wapp_u16_list_remove(U16List *list, u64 index) { - assert(list != NULL); + wapp_debug_assert(list != NULL, "`list` should not be NULL"); U16Node *output = NULL; @@ -2272,7 +2272,7 @@ RETURN_U16_LIST_REMOVE: } void wapp_u16_list_empty(U16List *list) { - assert(list != NULL); + wapp_debug_assert(list != NULL, "`list` should not be NULL"); u64 count = list->node_count; for (u64 i = 0; i < count; ++i) { @@ -2281,7 +2281,7 @@ void wapp_u16_list_empty(U16List *list) { } U32Node *wapp_u32_list_get(const U32List *list, u64 index) { - assert(index < list->node_count); + wapp_runtime_assert(index < list->node_count, "`index` is out of bounds"); U32Node *output = NULL; U32Node *current = list->first; @@ -2295,7 +2295,7 @@ U32Node *wapp_u32_list_get(const U32List *list, u64 index) { } void wapp_u32_list_push_front(U32List *list, U32Node *node) { - assert(list != NULL && node != NULL && (node->item) != NULL); + wapp_debug_assert(list != NULL && node != NULL && (node->item) != NULL, "`list`, `node` and `node->item` should not be NULL"); U32List node_list = u32_node_to_list(node); @@ -2316,7 +2316,7 @@ void wapp_u32_list_push_front(U32List *list, U32Node *node) { } void wapp_u32_list_push_back(U32List *list, U32Node *node) { - assert(list != NULL && node != NULL && (node->item) != NULL); + wapp_debug_assert(list != NULL && node != NULL && (node->item) != NULL, "`list`, `node` and `node->item` should not be NULL"); U32List node_list = u32_node_to_list(node); @@ -2337,7 +2337,7 @@ void wapp_u32_list_push_back(U32List *list, U32Node *node) { } void wapp_u32_list_insert(U32List *list, U32Node *node, u64 index) { - assert(list != NULL && node != NULL && (node->item) != NULL); + wapp_debug_assert(list != NULL && node != NULL && (node->item) != NULL, "`list`, `node` and `node->item` should not be NULL"); if (index == 0) { wapp_u32_list_push_front(list, node); @@ -2366,7 +2366,7 @@ void wapp_u32_list_insert(U32List *list, U32Node *node, u64 index) { } U32Node *wapp_u32_list_pop_front(U32List *list) { - assert(list != NULL); + wapp_debug_assert(list != NULL, "`list` should not be NULL"); U32Node *output = NULL; @@ -2391,7 +2391,7 @@ RETURN_U32_LIST_POP_FRONT: } U32Node *wapp_u32_list_pop_back(U32List *list) { - assert(list != NULL); + wapp_debug_assert(list != NULL, "`list` should not be NULL"); U32Node *output = NULL; @@ -2416,7 +2416,7 @@ RETURN_U32_LIST_POP_BACK: } U32Node *wapp_u32_list_remove(U32List *list, u64 index) { - assert(list != NULL); + wapp_debug_assert(list != NULL, "`list` should not be NULL"); U32Node *output = NULL; @@ -2445,7 +2445,7 @@ RETURN_U32_LIST_REMOVE: } void wapp_u32_list_empty(U32List *list) { - assert(list != NULL); + wapp_debug_assert(list != NULL, "`list` should not be NULL"); u64 count = list->node_count; for (u64 i = 0; i < count; ++i) { @@ -2454,7 +2454,7 @@ void wapp_u32_list_empty(U32List *list) { } U64Node *wapp_u64_list_get(const U64List *list, u64 index) { - assert(index < list->node_count); + wapp_runtime_assert(index < list->node_count, "`index` is out of bounds"); U64Node *output = NULL; U64Node *current = list->first; @@ -2468,7 +2468,7 @@ U64Node *wapp_u64_list_get(const U64List *list, u64 index) { } void wapp_u64_list_push_front(U64List *list, U64Node *node) { - assert(list != NULL && node != NULL && (node->item) != NULL); + wapp_debug_assert(list != NULL && node != NULL && (node->item) != NULL, "`list`, `node` and `node->item` should not be NULL"); U64List node_list = u64_node_to_list(node); @@ -2489,7 +2489,7 @@ void wapp_u64_list_push_front(U64List *list, U64Node *node) { } void wapp_u64_list_push_back(U64List *list, U64Node *node) { - assert(list != NULL && node != NULL && (node->item) != NULL); + wapp_debug_assert(list != NULL && node != NULL && (node->item) != NULL, "`list`, `node` and `node->item` should not be NULL"); U64List node_list = u64_node_to_list(node); @@ -2510,7 +2510,7 @@ void wapp_u64_list_push_back(U64List *list, U64Node *node) { } void wapp_u64_list_insert(U64List *list, U64Node *node, u64 index) { - assert(list != NULL && node != NULL && (node->item) != NULL); + wapp_debug_assert(list != NULL && node != NULL && (node->item) != NULL, "`list`, `node` and `node->item` should not be NULL"); if (index == 0) { wapp_u64_list_push_front(list, node); @@ -2539,7 +2539,7 @@ void wapp_u64_list_insert(U64List *list, U64Node *node, u64 index) { } U64Node *wapp_u64_list_pop_front(U64List *list) { - assert(list != NULL); + wapp_debug_assert(list != NULL, "`list` should not be NULL"); U64Node *output = NULL; @@ -2564,7 +2564,7 @@ RETURN_U64_LIST_POP_FRONT: } U64Node *wapp_u64_list_pop_back(U64List *list) { - assert(list != NULL); + wapp_debug_assert(list != NULL, "`list` should not be NULL"); U64Node *output = NULL; @@ -2589,7 +2589,7 @@ RETURN_U64_LIST_POP_BACK: } U64Node *wapp_u64_list_remove(U64List *list, u64 index) { - assert(list != NULL); + wapp_debug_assert(list != NULL, "`list` should not be NULL"); U64Node *output = NULL; @@ -2618,7 +2618,7 @@ RETURN_U64_LIST_REMOVE: } void wapp_u64_list_empty(U64List *list) { - assert(list != NULL); + wapp_debug_assert(list != NULL, "`list` should not be NULL"); u64 count = list->node_count; for (u64 i = 0; i < count; ++i) { @@ -2627,7 +2627,7 @@ void wapp_u64_list_empty(U64List *list) { } F32Node *wapp_f32_list_get(const F32List *list, u64 index) { - assert(index < list->node_count); + wapp_runtime_assert(index < list->node_count, "`index` is out of bounds"); F32Node *output = NULL; F32Node *current = list->first; @@ -2641,7 +2641,7 @@ F32Node *wapp_f32_list_get(const F32List *list, u64 index) { } void wapp_f32_list_push_front(F32List *list, F32Node *node) { - assert(list != NULL && node != NULL && (node->item) != NULL); + wapp_debug_assert(list != NULL && node != NULL && (node->item) != NULL, "`list`, `node` and `node->item` should not be NULL"); F32List node_list = f32_node_to_list(node); @@ -2662,7 +2662,7 @@ void wapp_f32_list_push_front(F32List *list, F32Node *node) { } void wapp_f32_list_push_back(F32List *list, F32Node *node) { - assert(list != NULL && node != NULL && (node->item) != NULL); + wapp_debug_assert(list != NULL && node != NULL && (node->item) != NULL, "`list`, `node` and `node->item` should not be NULL"); F32List node_list = f32_node_to_list(node); @@ -2683,7 +2683,7 @@ void wapp_f32_list_push_back(F32List *list, F32Node *node) { } void wapp_f32_list_insert(F32List *list, F32Node *node, u64 index) { - assert(list != NULL && node != NULL && (node->item) != NULL); + wapp_debug_assert(list != NULL && node != NULL && (node->item) != NULL, "`list`, `node` and `node->item` should not be NULL"); if (index == 0) { wapp_f32_list_push_front(list, node); @@ -2712,7 +2712,7 @@ void wapp_f32_list_insert(F32List *list, F32Node *node, u64 index) { } F32Node *wapp_f32_list_pop_front(F32List *list) { - assert(list != NULL); + wapp_debug_assert(list != NULL, "`list` should not be NULL"); F32Node *output = NULL; @@ -2737,7 +2737,7 @@ RETURN_F32_LIST_POP_FRONT: } F32Node *wapp_f32_list_pop_back(F32List *list) { - assert(list != NULL); + wapp_debug_assert(list != NULL, "`list` should not be NULL"); F32Node *output = NULL; @@ -2762,7 +2762,7 @@ RETURN_F32_LIST_POP_BACK: } F32Node *wapp_f32_list_remove(F32List *list, u64 index) { - assert(list != NULL); + wapp_debug_assert(list != NULL, "`list` should not be NULL"); F32Node *output = NULL; @@ -2791,7 +2791,7 @@ RETURN_F32_LIST_REMOVE: } void wapp_f32_list_empty(F32List *list) { - assert(list != NULL); + wapp_debug_assert(list != NULL, "`list` should not be NULL"); u64 count = list->node_count; for (u64 i = 0; i < count; ++i) { @@ -2800,7 +2800,7 @@ void wapp_f32_list_empty(F32List *list) { } F64Node *wapp_f64_list_get(const F64List *list, u64 index) { - assert(index < list->node_count); + wapp_runtime_assert(index < list->node_count, "`index` is out of bounds"); F64Node *output = NULL; F64Node *current = list->first; @@ -2814,7 +2814,7 @@ F64Node *wapp_f64_list_get(const F64List *list, u64 index) { } void wapp_f64_list_push_front(F64List *list, F64Node *node) { - assert(list != NULL && node != NULL && (node->item) != NULL); + wapp_debug_assert(list != NULL && node != NULL && (node->item) != NULL, "`list`, `node` and `node->item` should not be NULL"); F64List node_list = f64_node_to_list(node); @@ -2835,7 +2835,7 @@ void wapp_f64_list_push_front(F64List *list, F64Node *node) { } void wapp_f64_list_push_back(F64List *list, F64Node *node) { - assert(list != NULL && node != NULL && (node->item) != NULL); + wapp_debug_assert(list != NULL && node != NULL && (node->item) != NULL, "`list`, `node` and `node->item` should not be NULL"); F64List node_list = f64_node_to_list(node); @@ -2856,7 +2856,7 @@ void wapp_f64_list_push_back(F64List *list, F64Node *node) { } void wapp_f64_list_insert(F64List *list, F64Node *node, u64 index) { - assert(list != NULL && node != NULL && (node->item) != NULL); + wapp_debug_assert(list != NULL && node != NULL && (node->item) != NULL, "`list`, `node` and `node->item` should not be NULL"); if (index == 0) { wapp_f64_list_push_front(list, node); @@ -2885,7 +2885,7 @@ void wapp_f64_list_insert(F64List *list, F64Node *node, u64 index) { } F64Node *wapp_f64_list_pop_front(F64List *list) { - assert(list != NULL); + wapp_debug_assert(list != NULL, "`list` should not be NULL"); F64Node *output = NULL; @@ -2910,7 +2910,7 @@ RETURN_F64_LIST_POP_FRONT: } F64Node *wapp_f64_list_pop_back(F64List *list) { - assert(list != NULL); + wapp_debug_assert(list != NULL, "`list` should not be NULL"); F64Node *output = NULL; @@ -2935,7 +2935,7 @@ RETURN_F64_LIST_POP_BACK: } F64Node *wapp_f64_list_remove(F64List *list, u64 index) { - assert(list != NULL); + wapp_debug_assert(list != NULL, "`list` should not be NULL"); F64Node *output = NULL; @@ -2964,7 +2964,7 @@ RETURN_F64_LIST_REMOVE: } void wapp_f64_list_empty(F64List *list) { - assert(list != NULL); + wapp_debug_assert(list != NULL, "`list` should not be NULL"); u64 count = list->node_count; for (u64 i = 0; i < count; ++i) { @@ -2973,7 +2973,7 @@ void wapp_f64_list_empty(F64List *list) { } F128Node *wapp_f128_list_get(const F128List *list, u64 index) { - assert(index < list->node_count); + wapp_runtime_assert(index < list->node_count, "`index` is out of bounds"); F128Node *output = NULL; F128Node *current = list->first; @@ -2987,7 +2987,7 @@ F128Node *wapp_f128_list_get(const F128List *list, u64 index) { } void wapp_f128_list_push_front(F128List *list, F128Node *node) { - assert(list != NULL && node != NULL && (node->item) != NULL); + wapp_debug_assert(list != NULL && node != NULL && (node->item) != NULL, "`list`, `node` and `node->item` should not be NULL"); F128List node_list = f128_node_to_list(node); @@ -3008,7 +3008,7 @@ void wapp_f128_list_push_front(F128List *list, F128Node *node) { } void wapp_f128_list_push_back(F128List *list, F128Node *node) { - assert(list != NULL && node != NULL && (node->item) != NULL); + wapp_debug_assert(list != NULL && node != NULL && (node->item) != NULL, "`list`, `node` and `node->item` should not be NULL"); F128List node_list = f128_node_to_list(node); @@ -3029,7 +3029,7 @@ void wapp_f128_list_push_back(F128List *list, F128Node *node) { } void wapp_f128_list_insert(F128List *list, F128Node *node, u64 index) { - assert(list != NULL && node != NULL && (node->item) != NULL); + wapp_debug_assert(list != NULL && node != NULL && (node->item) != NULL, "`list`, `node` and `node->item` should not be NULL"); if (index == 0) { wapp_f128_list_push_front(list, node); @@ -3058,7 +3058,7 @@ void wapp_f128_list_insert(F128List *list, F128Node *node, u64 index) { } F128Node *wapp_f128_list_pop_front(F128List *list) { - assert(list != NULL); + wapp_debug_assert(list != NULL, "`list` should not be NULL"); F128Node *output = NULL; @@ -3083,7 +3083,7 @@ RETURN_F128_LIST_POP_FRONT: } F128Node *wapp_f128_list_pop_back(F128List *list) { - assert(list != NULL); + wapp_debug_assert(list != NULL, "`list` should not be NULL"); F128Node *output = NULL; @@ -3108,7 +3108,7 @@ RETURN_F128_LIST_POP_BACK: } F128Node *wapp_f128_list_remove(F128List *list, u64 index) { - assert(list != NULL); + wapp_debug_assert(list != NULL, "`list` should not be NULL"); F128Node *output = NULL; @@ -3137,7 +3137,7 @@ RETURN_F128_LIST_REMOVE: } void wapp_f128_list_empty(F128List *list) { - assert(list != NULL); + wapp_debug_assert(list != NULL, "`list` should not be NULL"); u64 count = list->node_count; for (u64 i = 0; i < count; ++i) { @@ -3146,7 +3146,7 @@ void wapp_f128_list_empty(F128List *list) { } IptrNode *wapp_iptr_list_get(const IptrList *list, u64 index) { - assert(index < list->node_count); + wapp_runtime_assert(index < list->node_count, "`index` is out of bounds"); IptrNode *output = NULL; IptrNode *current = list->first; @@ -3160,7 +3160,7 @@ IptrNode *wapp_iptr_list_get(const IptrList *list, u64 index) { } void wapp_iptr_list_push_front(IptrList *list, IptrNode *node) { - assert(list != NULL && node != NULL && (node->item) != NULL); + wapp_debug_assert(list != NULL && node != NULL && (node->item) != NULL, "`list`, `node` and `node->item` should not be NULL"); IptrList node_list = iptr_node_to_list(node); @@ -3181,7 +3181,7 @@ void wapp_iptr_list_push_front(IptrList *list, IptrNode *node) { } void wapp_iptr_list_push_back(IptrList *list, IptrNode *node) { - assert(list != NULL && node != NULL && (node->item) != NULL); + wapp_debug_assert(list != NULL && node != NULL && (node->item) != NULL, "`list`, `node` and `node->item` should not be NULL"); IptrList node_list = iptr_node_to_list(node); @@ -3202,7 +3202,7 @@ void wapp_iptr_list_push_back(IptrList *list, IptrNode *node) { } void wapp_iptr_list_insert(IptrList *list, IptrNode *node, u64 index) { - assert(list != NULL && node != NULL && (node->item) != NULL); + wapp_debug_assert(list != NULL && node != NULL && (node->item) != NULL, "`list`, `node` and `node->item` should not be NULL"); if (index == 0) { wapp_iptr_list_push_front(list, node); @@ -3231,7 +3231,7 @@ void wapp_iptr_list_insert(IptrList *list, IptrNode *node, u64 index) { } IptrNode *wapp_iptr_list_pop_front(IptrList *list) { - assert(list != NULL); + wapp_debug_assert(list != NULL, "`list` should not be NULL"); IptrNode *output = NULL; @@ -3256,7 +3256,7 @@ RETURN_IPTR_LIST_POP_FRONT: } IptrNode *wapp_iptr_list_pop_back(IptrList *list) { - assert(list != NULL); + wapp_debug_assert(list != NULL, "`list` should not be NULL"); IptrNode *output = NULL; @@ -3281,7 +3281,7 @@ RETURN_IPTR_LIST_POP_BACK: } IptrNode *wapp_iptr_list_remove(IptrList *list, u64 index) { - assert(list != NULL); + wapp_debug_assert(list != NULL, "`list` should not be NULL"); IptrNode *output = NULL; @@ -3310,7 +3310,7 @@ RETURN_IPTR_LIST_REMOVE: } void wapp_iptr_list_empty(IptrList *list) { - assert(list != NULL); + wapp_debug_assert(list != NULL, "`list` should not be NULL"); u64 count = list->node_count; for (u64 i = 0; i < count; ++i) { @@ -3319,7 +3319,7 @@ void wapp_iptr_list_empty(IptrList *list) { } UptrNode *wapp_uptr_list_get(const UptrList *list, u64 index) { - assert(index < list->node_count); + wapp_runtime_assert(index < list->node_count, "`index` is out of bounds"); UptrNode *output = NULL; UptrNode *current = list->first; @@ -3333,7 +3333,7 @@ UptrNode *wapp_uptr_list_get(const UptrList *list, u64 index) { } void wapp_uptr_list_push_front(UptrList *list, UptrNode *node) { - assert(list != NULL && node != NULL && (node->item) != NULL); + wapp_debug_assert(list != NULL && node != NULL && (node->item) != NULL, "`list`, `node` and `node->item` should not be NULL"); UptrList node_list = uptr_node_to_list(node); @@ -3354,7 +3354,7 @@ void wapp_uptr_list_push_front(UptrList *list, UptrNode *node) { } void wapp_uptr_list_push_back(UptrList *list, UptrNode *node) { - assert(list != NULL && node != NULL && (node->item) != NULL); + wapp_debug_assert(list != NULL && node != NULL && (node->item) != NULL, "`list`, `node` and `node->item` should not be NULL"); UptrList node_list = uptr_node_to_list(node); @@ -3375,7 +3375,7 @@ void wapp_uptr_list_push_back(UptrList *list, UptrNode *node) { } void wapp_uptr_list_insert(UptrList *list, UptrNode *node, u64 index) { - assert(list != NULL && node != NULL && (node->item) != NULL); + wapp_debug_assert(list != NULL && node != NULL && (node->item) != NULL, "`list`, `node` and `node->item` should not be NULL"); if (index == 0) { wapp_uptr_list_push_front(list, node); @@ -3404,7 +3404,7 @@ void wapp_uptr_list_insert(UptrList *list, UptrNode *node, u64 index) { } UptrNode *wapp_uptr_list_pop_front(UptrList *list) { - assert(list != NULL); + wapp_debug_assert(list != NULL, "`list` should not be NULL"); UptrNode *output = NULL; @@ -3429,7 +3429,7 @@ RETURN_UPTR_LIST_POP_FRONT: } UptrNode *wapp_uptr_list_pop_back(UptrList *list) { - assert(list != NULL); + wapp_debug_assert(list != NULL, "`list` should not be NULL"); UptrNode *output = NULL; @@ -3454,7 +3454,7 @@ RETURN_UPTR_LIST_POP_BACK: } UptrNode *wapp_uptr_list_remove(UptrList *list, u64 index) { - assert(list != NULL); + wapp_debug_assert(list != NULL, "`list` should not be NULL"); UptrNode *output = NULL; @@ -3483,7 +3483,7 @@ RETURN_UPTR_LIST_REMOVE: } void wapp_uptr_list_empty(UptrList *list) { - assert(list != NULL); + wapp_debug_assert(list != NULL, "`list` should not be NULL"); u64 count = list->node_count; for (u64 i = 0; i < count; ++i) { @@ -3523,8 +3523,8 @@ internal VoidPList void_ptr_node_to_list(VoidPNode *node) { return output; } -internal BoolList bool_node_to_list(BoolNode *node) { - BoolList output = {.first = node, .last = node, .node_count = 1}; +internal B32List b32_node_to_list(B32Node *node) { + B32List output = {.first = node, .last = node, .node_count = 1}; while (output.first->prev != NULL) { output.first = output.first->prev; diff --git a/src/primitives/dbl_list/dbl_list.h b/src/primitives/dbl_list/dbl_list.h index 17e2d11..58fb6b7 100644 --- a/src/primitives/dbl_list/dbl_list.h +++ b/src/primitives/dbl_list/dbl_list.h @@ -5,13 +5,13 @@ #ifndef DBL_LIST_H #define DBL_LIST_H +#include "../../common/aliases/aliases.h" #include "../../common/aliases/aliases.h" #include "../../common/platform/platform.h" -#include #define wapp_str8_list_node(ITEM_PTR) ((Str8Node){.item = ITEM_PTR}) #define wapp_void_ptr_list_node(ITEM_PTR) ((VoidPNode){.item = ITEM_PTR}) -#define wapp_bool_list_node(ITEM_PTR) ((BoolNode){.item = ITEM_PTR}) +#define wapp_b32_list_node(ITEM_PTR) ((B32Node){.item = ITEM_PTR}) #define wapp_char_list_node(ITEM_PTR) ((CharNode){.item = ITEM_PTR}) #define wapp_c8_list_node(ITEM_PTR) ((C8Node){.item = ITEM_PTR}) #define wapp_c16_list_node(ITEM_PTR) ((C16Node){.item = ITEM_PTR}) @@ -60,17 +60,17 @@ struct VoidPList { u64 node_count; }; -typedef struct BoolNode BoolNode; -struct BoolNode { - bool *item; - BoolNode *prev; - BoolNode *next; +typedef struct B32Node B32Node; +struct B32Node { + b32 *item; + B32Node *prev; + B32Node *next; }; -typedef struct BoolList BoolList; -struct BoolList { - BoolNode *first; - BoolNode *last; +typedef struct B32List B32List; +struct B32List { + B32Node *first; + B32Node *last; u64 node_count; }; @@ -328,14 +328,14 @@ VoidPNode *wapp_void_ptr_list_pop_front(VoidPList *list); VoidPNode *wapp_void_ptr_list_pop_back(VoidPList *list); VoidPNode *wapp_void_ptr_list_remove(VoidPList *list, u64 index); void wapp_void_ptr_list_empty(VoidPList *list); -BoolNode *wapp_bool_list_get(const BoolList *list, u64 index); -void wapp_bool_list_push_front(BoolList *list, BoolNode *node); -void wapp_bool_list_push_back(BoolList *list, BoolNode *node); -void wapp_bool_list_insert(BoolList *list, BoolNode *node, u64 index); -BoolNode *wapp_bool_list_pop_front(BoolList *list); -BoolNode *wapp_bool_list_pop_back(BoolList *list); -BoolNode *wapp_bool_list_remove(BoolList *list, u64 index); -void wapp_bool_list_empty(BoolList *list); +B32Node *wapp_b32_list_get(const B32List *list, u64 index); +void wapp_b32_list_push_front(B32List *list, B32Node *node); +void wapp_b32_list_push_back(B32List *list, B32Node *node); +void wapp_b32_list_insert(B32List *list, B32Node *node, u64 index); +B32Node *wapp_b32_list_pop_front(B32List *list); +B32Node *wapp_b32_list_pop_back(B32List *list); +B32Node *wapp_b32_list_remove(B32List *list, u64 index); +void wapp_b32_list_empty(B32List *list); CharNode *wapp_char_list_get(const CharList *list, u64 index); void wapp_char_list_push_front(CharList *list, CharNode *node); void wapp_char_list_push_back(CharList *list, CharNode *node);