From 3d6755d4d476a88871d9f33f995060e4b27c0fde Mon Sep 17 00:00:00 2001 From: Abdelrahman Date: Mon, 23 Nov 2026 00:44:54 +0000 Subject: [PATCH] Apply arena initialisation fixes --- CHANGELOG.md | 6 ++++++ VERSION | 2 +- src/base/mem/allocator/mem_allocator.h | 5 ++--- src/os/allocators/arena/mem_arena.c | 12 ++++++------ 4 files changed, 15 insertions(+), 10 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f7bbe13..6dfe1b5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/VERSION b/VERSION index 40c341b..9575d51 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -3.6.0 +3.6.1 diff --git a/src/base/mem/allocator/mem_allocator.h b/src/base/mem/allocator/mem_allocator.h index f62dd71..c258a66 100644 --- a/src/base/mem/allocator/mem_allocator.h +++ b/src/base/mem/allocator/mem_allocator.h @@ -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) ([&]() { \ diff --git a/src/os/allocators/arena/mem_arena.c b/src/os/allocators/arena/mem_arena.c index b925270..929dd58 100644 --- a/src/os/allocators/arena/mem_arena.c +++ b/src/os/allocators/arena/mem_arena.c @@ -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;