@@ -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
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user