This commit is contained in:
1 parent
ae7a0806df
commit
3d6755d4d4
4 files changed
+15
-10
No files matched your search
@@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||
|
||||
## [Unreleased]
|
||||
|
||||
## [3.6.1] - 2026-11-23
|
||||
|
||||
### Fixed
|
||||
|
||||
- Arena initialisation checks
|
||||
|
||||
## [3.6.0] - 2026-11-22
|
||||
|
||||
### Added
|
||||
|
||||
@@ -38,8 +38,7 @@ typedef void (WpMemTempBeginFunc)(void *alloc_obj);
|
||||
typedef void (WpMemTempEndFunc)(void *alloc_obj);
|
||||
typedef WpAllocatorUsage (WpMemQueryUsageFunc)(void *alloc_obj);
|
||||
|
||||
typedef struct WpAllocator WpAllocator;
|
||||
struct WpAllocator {
|
||||
typedef struct WpAllocator {
|
||||
void *obj;
|
||||
WpMemAllocFunc *alloc;
|
||||
WpMemAllocAlignedFunc *alloc_aligned;
|
||||
@@ -49,7 +48,7 @@ struct WpAllocator {
|
||||
WpMemTempBeginFunc *temp_begin;
|
||||
WpMemTempEndFunc *temp_end;
|
||||
WpMemQueryUsageFunc *query_usage;
|
||||
};
|
||||
} WpAllocator;
|
||||
|
||||
#ifdef WP_PLATFORM_CPP
|
||||
#define wpMemAllocatorInvalid(ALLOCATOR) ([&]() { \
|
||||
|
||||
@@ -33,11 +33,11 @@ struct WpArena {
|
||||
};
|
||||
|
||||
b8 wpMemArenaInitBuffer(WpArena **arena, u8 *buffer, u64 buffer_size) {
|
||||
if (!arena || *arena || buffer_size < sizeof(WpArena)) {
|
||||
if (arena == NULL || *arena != NULL || buffer_size < sizeof(WpArena)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
*arena = (WpArena *)buffer;
|
||||
*arena = (WpArena *)buffer;
|
||||
WpArena *arena_ptr = *arena;
|
||||
|
||||
arena_ptr->buf = (u8 *)(arena_ptr + 1);
|
||||
@@ -51,15 +51,15 @@ b8 wpMemArenaInitBuffer(WpArena **arena, u8 *buffer, u64 buffer_size) {
|
||||
}
|
||||
|
||||
b8 wpMemArenaInitAllocatedCustom(WpArena **arena, u64 base_capacity, WpMemAllocFlags flags, b8 zero_buffer) {
|
||||
if (!arena || *arena || base_capacity == 0) {
|
||||
if (arena == NULL || *arena != NULL || base_capacity == 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
u64 size = sizeof(WpArena) + (base_capacity >= ARENA_MINIMUM_CAPACITY ? base_capacity : ARENA_MINIMUM_CAPACITY);
|
||||
u64 alloc_size = wpMiscUtilsU64RoundUpPow2(size);
|
||||
u8 *allocated = (u8 *)wpOsMemAlloc(NULL, alloc_size, WP_MEM_ACCESS_READ_WRITE, flags,
|
||||
zero_buffer ? WP_MEM_INIT_INITIALISED : WP_MEM_INIT_UNINITIALISED);
|
||||
if (!allocated) {
|
||||
zero_buffer ? WP_MEM_INIT_INITIALISED : WP_MEM_INIT_UNINITIALISED);
|
||||
if (allocated == NULL) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -77,7 +77,7 @@ b8 wpMemArenaInitAllocatedCustom(WpArena **arena, u64 base_capacity, WpMemAllocF
|
||||
return false;
|
||||
}
|
||||
|
||||
WpArena *arena_ptr = *arena;
|
||||
WpArena *arena_ptr = *arena;
|
||||
arena_ptr->type = ARENA_STORAGE_TYPE_ALLOCATED;
|
||||
arena_ptr->committed = committed;
|
||||
|
||||
|
||||
Reference in new issue
Block a user