Add wpArrayZero
Release / release (push) Successful in 3s

This commit is contained in:
2026-09-16 01:28:11 +01:00
parent f73a870a34
commit 605c1ddfae
3 changed files with 12 additions and 3 deletions
+1
View File
@@ -24,6 +24,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- `WpSplitmix64State`
- `wpPrngSplitmix64Init`, `wpPrngSplitmix64InitWithSeed`, `wpPrngSplitmix64`, `wpPrngSplitmix64InRange`, `wpPrngSplitmix64Choice`
- `wpStr8Clear`
- `wpArrayZero` to zero all elements in an array without setting the count to 0
### Changed
+8
View File
@@ -208,6 +208,14 @@ void *arrayPop(WpArray array, u64 item_size) {
return out;
}
void arrayZero(WpArray array, u64 item_size) {
wpRuntimeAssert(array != NULL, "`array` should not be NULL");
arrayValidate(array, item_size);
WpArrayHeader *header = arrayHeader(array);
memset(array, 0, header->capacity * header->item_size);
}
void arrayClear(WpArray array, u64 item_size) {
wpRuntimeAssert(array != NULL, "`array` should not be NULL");
arrayValidate(array, item_size);
+3 -3
View File
@@ -168,9 +168,8 @@ typedef enum WpArrayInitFlags {
(WpArray)SRC_ARRAY, \
FLAGS, \
sizeof(TYPE)))
#define wpArrayClear(TYPE, ARRAY) \
(arrayClear((WpArray)ARRAY, \
sizeof(TYPE)))
#define wpArrayZero(TYPE, ARRAY) (arrayZero((WpArray)ARRAY, sizeof(TYPE)))
#define wpArrayClear(TYPE, ARRAY) (arrayClear((WpArray)ARRAY, sizeof(TYPE)))
#define wpArrayCalcAllocSize(TYPE, CAPACITY) arrayCalcAllocSize(CAPACITY, sizeof(TYPE))
#define wpArrayAllocCapacity(TYPE, ALLOCATOR_PTR, CAPACITY, FLAGS) \
((TYPE *)arrayAllocCapacity(ALLOCATOR_PTR, CAPACITY, FLAGS, sizeof(TYPE)))
@@ -206,6 +205,7 @@ WpArray arrayExtendAlloc(const WpAllocator *allocator, WpArray dst, const WpArra
WpArray arrayCopyAlloc(const WpAllocator *allocator, WpArray dst, const WpArray src,
WpArrayInitFlags flags, u64 item_size);
void *arrayPop(WpArray array, u64 item_size);
void arrayZero(WpArray array, u64 item_size);
void arrayClear(WpArray array, u64 item_size);
u64 arrayCalcAllocSize(u64 capacity, u64 item_size);
WpArray arrayAllocCapacity(const WpAllocator *allocator, u64 capacity, WpArrayInitFlags flags,