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