Switch array NULL pointer checks to debug asserts
Release / release (push) Successful in 2s

This commit is contained in:
2026-09-21 07:41:46 +01:00
parent e90229db7a
commit ac5baef3b8
+14 -14
View File
@@ -49,7 +49,7 @@ void arraySetCount(WpArray array, u64 count) {
} }
void *arrayGet(WpArray array, u64 index, u64 item_size) { 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); arrayValidate(array, item_size);
WpArrayHeader *header = arrayHeader(array); 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) { 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); arrayValidate(array, item_size);
WpArrayHeader *header = arrayHeader(array); 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) { 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(dst, item_size);
arrayValidate(src, 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) { 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(dst, item_size);
arrayValidate(src, 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, WpArray arrayAppendAlloc(const WpAllocator *allocator, WpArray array, void *value,
WpArrayInitFlags flags, u64 item_size) { 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); arrayValidate(array, item_size);
WpArray output = array; WpArray output = array;
@@ -136,7 +136,7 @@ RETURN_ARRAY_APPEND_ALLOC:
WpArray arrayExtendAlloc(const WpAllocator *allocator, WpArray dst, const WpArray src, WpArray arrayExtendAlloc(const WpAllocator *allocator, WpArray dst, const WpArray src,
WpArrayInitFlags flags, u64 item_size) { 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(dst, item_size);
arrayValidate(src, item_size); arrayValidate(src, item_size);
@@ -168,7 +168,7 @@ RETURN_ARRAY_EXTEND_ALLOC:
WpArray arrayCopyAlloc(const WpAllocator *allocator, WpArray dst, const WpArray src, WpArray arrayCopyAlloc(const WpAllocator *allocator, WpArray dst, const WpArray src,
WpArrayInitFlags flags, u64 item_size) { 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(dst, item_size);
arrayValidate(src, item_size); arrayValidate(src, item_size);
@@ -197,7 +197,7 @@ RETURN_ARRAY_COPY_ALLOC:
} }
void arrayRemoveSwapEnd(WpArray array, u64 index, u64 item_size) { 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); arrayValidate(array, item_size);
WpArrayHeader *header = arrayHeader(array); WpArrayHeader *header = arrayHeader(array);
@@ -213,7 +213,7 @@ void arrayRemoveSwapEnd(WpArray array, u64 index, u64 item_size) {
} }
void *arrayPop(WpArray array, 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); arrayValidate(array, item_size);
WpArrayHeader *header = arrayHeader(array); WpArrayHeader *header = arrayHeader(array);
@@ -226,7 +226,7 @@ void *arrayPop(WpArray array, u64 item_size) {
} }
void arrayZero(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); arrayValidate(array, item_size);
WpArrayHeader *header = arrayHeader(array); WpArrayHeader *header = arrayHeader(array);
@@ -234,7 +234,7 @@ void arrayZero(WpArray array, u64 item_size) {
} }
void arrayClear(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); arrayValidate(array, item_size);
WpArrayHeader *header = arrayHeader(array); WpArrayHeader *header = arrayHeader(array);
@@ -248,7 +248,7 @@ u64 arrayCalcAllocSize(u64 capacity, u64 item_size) {
WpArray arrayAllocCapacity(const WpAllocator *allocator, u64 capacity, WpArrayInitFlags flags, WpArray arrayAllocCapacity(const WpAllocator *allocator, u64 capacity, WpArrayInitFlags flags,
u64 item_size) { u64 item_size) {
wpRuntimeAssert(allocator != NULL, "`allocator` should not be NULL"); wpDebugAssert(allocator != NULL, "`allocator` should not be NULL");
WpArray output = NULL; WpArray output = NULL;
@@ -267,7 +267,7 @@ RETURN_ARRAY_ALLOC:
WpArray arrayFromPreallocatedBuffer(void *buffer, u64 buffer_size, WpArrayInitFlags flags, WpArray arrayFromPreallocatedBuffer(void *buffer, u64 buffer_size, WpArrayInitFlags flags,
u64 item_size) { 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)); i64 data_buffer_size = (i64)buffer_size - (i64)(sizeof(WpArrayHeader));
if (data_buffer_size <= 0) { 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) { 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 capacity = wpArrayCapacity(*array);
u64 allocation_size = arrayCalcAllocSize(capacity, item_size); u64 allocation_size = arrayCalcAllocSize(capacity, item_size);