Skip to content

fix(memory): fix ArenaAllocator and PoolAllocator bugs (#680 #681 #682 #683 #697) - #720

Merged
JeanPhilippeKernel merged 1 commit into
developfrom
fix/memory-allocator-bugs
Sep 1, 2026
Merged

JeanPhilippeKernel merged 1 commit into
developfrom
fix/memory-allocator-bugs

Conversation

@JeanPhilippeKernel

Copy link
Copy Markdown
Owner

Fixes #680, #681, #682, #683, #697

#680 ArenaAllocator::Allocate — explicit power-of-two alignment precondition via ZENGINE_VALIDATE_ASSERT

#683 Extract ArenaAllocateRaw internal helper; Allocate calls it and zeroes; new AllocateNoZero skips zeroing — saves ~0.4 ms for 16 MB+ decode buffers

#681 PoolAllocator::Allocate — assert on pool exhaustion instead of silent null return

#682 PoolAllocator::Free + Clear::new (ptr) PoolFreeNode{} placement new instead of C-style cast; correctly begins object lifetime per C++ object model

#697 PoolAllocator::Free#ifndef NDEBUG free-list scan detects double-free before inserting

…681 #682 #683 #697

#680 — ArenaAllocator::Allocate: add explicit power-of-two alignment precondition
  (ZENGINE_VALIDATE_ASSERT before any work, even if m_memory is null)

#683 — ArenaAllocator: extract ArenaAllocateRaw internal helper; Allocate calls it
  then zeroes; new AllocateNoZero calls it without zeroing — saves ~0.4 ms for
  16 MB+ allocations where the caller initialises the memory fully before reading

#681 — PoolAllocator::Allocate: replace silent null return on exhaustion with
  ZENGINE_VALIDATE_ASSERT — pool exhaustion is always a programmer error

#682 — PoolAllocator::Free + Clear: replace C-style (PoolFreeNode*)ptr casts with
  ::new (ptr) PoolFreeNode{} placement new to correctly begin object lifetime per
  the C++ object model (PoolFreeNode is trivially constructible — identical codegen)

#697 — PoolAllocator::Free: add #ifndef NDEBUG free-list scan to detect double-free;
  walks the free list before inserting and asserts the pointer is not already there
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment