From ac5baef3b889ba9fa5ec0a415d2c63b7835ee2ec Mon Sep 17 00:00:00 2001 From: Abdelrahman Date: Mon, 21 Sep 2026 07:41:46 +0100 Subject: [PATCH] Switch array NULL pointer checks to debug asserts --- src/base/array/array.c | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/src/base/array/array.c b/src/base/array/array.c index 19ab352..79f070d 100644 --- a/src/base/array/array.c +++ b/src/base/array/array.c @@ -49,7 +49,7 @@ void arraySetCount(WpArray array, u64 count) { } void *arrayGet(WpArray array, u64 index, u64 item_size) { - wpRuntimeAssert(array != NULL, "`array` should not be NULL"); + wpDebugAssert(array != NULL, "`array` should not be NULL"); arrayValidate(array, item_size); WpArrayHeader *header = arrayHeader(array); @@ -66,7 +66,7 @@ void arraySet(WpArray array, u64 index, void *value, u64 item_size) { } void arrayAppendCapped(WpArray array, void *value, u64 item_size) { - wpRuntimeAssert(array != NULL, "`array` should not be NULL"); + wpDebugAssert(array != NULL, "`array` should not be NULL"); arrayValidate(array, item_size); WpArrayHeader *header = arrayHeader(array); @@ -77,7 +77,7 @@ void arrayAppendCapped(WpArray array, void *value, u64 item_size) { } void arrayExtendCappend(WpArray dst, const WpArray src, u64 item_size) { - wpRuntimeAssert(dst != NULL && src != NULL, "`dst` and `src` should not be NULL"); + wpDebugAssert(dst != NULL && src != NULL, "`dst` and `src` should not be NULL"); arrayValidate(dst, item_size); arrayValidate(src, item_size); @@ -92,7 +92,7 @@ void arrayExtendCappend(WpArray dst, const WpArray src, u64 item_size) { } void arrayCopyCapped(WpArray dst, const WpArray src, u64 item_size) { - wpRuntimeAssert(dst != NULL && src != NULL, "`dst` and `src` should not be NULL"); + wpDebugAssert(dst != NULL && src != NULL, "`dst` and `src` should not be NULL"); arrayValidate(dst, item_size); arrayValidate(src, item_size); @@ -107,7 +107,7 @@ void arrayCopyCapped(WpArray dst, const WpArray src, u64 item_size) { WpArray arrayAppendAlloc(const WpAllocator *allocator, WpArray array, void *value, WpArrayInitFlags flags, u64 item_size) { - wpRuntimeAssert(allocator != NULL && array != NULL, "`allocator` and `array` should not be NULL"); + wpDebugAssert(allocator != NULL && array != NULL, "`allocator` and `array` should not be NULL"); arrayValidate(array, item_size); WpArray output = array; @@ -136,7 +136,7 @@ RETURN_ARRAY_APPEND_ALLOC: WpArray arrayExtendAlloc(const WpAllocator *allocator, WpArray dst, const WpArray src, WpArrayInitFlags flags, u64 item_size) { - wpRuntimeAssert(allocator != NULL && dst != NULL && src != NULL, "`allocator`, `dst` and `src` should not be NULL"); + wpDebugAssert(allocator != NULL && dst != NULL && src != NULL, "`allocator`, `dst` and `src` should not be NULL"); arrayValidate(dst, item_size); arrayValidate(src, item_size); @@ -168,7 +168,7 @@ RETURN_ARRAY_EXTEND_ALLOC: WpArray arrayCopyAlloc(const WpAllocator *allocator, WpArray dst, const WpArray src, WpArrayInitFlags flags, u64 item_size) { - wpRuntimeAssert(allocator != NULL && dst != NULL && src != NULL, "`allocator`, `dst` and `src` should not be NULL"); + wpDebugAssert(allocator != NULL && dst != NULL && src != NULL, "`allocator`, `dst` and `src` should not be NULL"); arrayValidate(dst, item_size); arrayValidate(src, item_size); @@ -197,7 +197,7 @@ RETURN_ARRAY_COPY_ALLOC: } void arrayRemoveSwapEnd(WpArray array, u64 index, u64 item_size) { - wpRuntimeAssert(array != NULL, "`array` should not be NULL"); + wpDebugAssert(array != NULL, "`array` should not be NULL"); arrayValidate(array, item_size); WpArrayHeader *header = arrayHeader(array); @@ -213,7 +213,7 @@ void arrayRemoveSwapEnd(WpArray array, u64 index, u64 item_size) { } void *arrayPop(WpArray array, u64 item_size) { - wpRuntimeAssert(array != NULL, "`array` should not be NULL"); + wpDebugAssert(array != NULL, "`array` should not be NULL"); arrayValidate(array, item_size); WpArrayHeader *header = arrayHeader(array); @@ -226,7 +226,7 @@ void *arrayPop(WpArray array, u64 item_size) { } void arrayZero(WpArray array, u64 item_size) { - wpRuntimeAssert(array != NULL, "`array` should not be NULL"); + wpDebugAssert(array != NULL, "`array` should not be NULL"); arrayValidate(array, item_size); WpArrayHeader *header = arrayHeader(array); @@ -234,7 +234,7 @@ void arrayZero(WpArray array, u64 item_size) { } void arrayClear(WpArray array, u64 item_size) { - wpRuntimeAssert(array != NULL, "`array` should not be NULL"); + wpDebugAssert(array != NULL, "`array` should not be NULL"); arrayValidate(array, item_size); WpArrayHeader *header = arrayHeader(array); @@ -248,7 +248,7 @@ u64 arrayCalcAllocSize(u64 capacity, u64 item_size) { WpArray arrayAllocCapacity(const WpAllocator *allocator, u64 capacity, WpArrayInitFlags flags, u64 item_size) { - wpRuntimeAssert(allocator != NULL, "`allocator` should not be NULL"); + wpDebugAssert(allocator != NULL, "`allocator` should not be NULL"); WpArray output = NULL; @@ -267,7 +267,7 @@ RETURN_ARRAY_ALLOC: WpArray arrayFromPreallocatedBuffer(void *buffer, u64 buffer_size, WpArrayInitFlags flags, u64 item_size) { - wpRuntimeAssert(buffer != NULL, "`buffer` should not be NULL"); + wpDebugAssert(buffer != NULL, "`buffer` should not be NULL"); i64 data_buffer_size = (i64)buffer_size - (i64)(sizeof(WpArrayHeader)); if (data_buffer_size <= 0) { @@ -286,7 +286,7 @@ WpArray arrayFromPreallocatedBuffer(void *buffer, u64 buffer_size, WpArrayInitFl } void arrayDealloc(const WpAllocator *allocator, WpArray *array, u64 item_size) { - wpRuntimeAssert(allocator != NULL, "`allocator` should not be NULL"); + wpDebugAssert(allocator != NULL, "`allocator` should not be NULL"); u64 capacity = wpArrayCapacity(*array); u64 allocation_size = arrayCalcAllocSize(capacity, item_size);