fix(memory): fix ArenaAllocator and PoolAllocator bugs (#680 #681 #682 #683 #697) - #720
Merged
Merged
Conversation
…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
This was
linked to
issues
Sep 1, 2026
Closed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #680, #681, #682, #683, #697
#680
ArenaAllocator::Allocate— explicit power-of-two alignment precondition viaZENGINE_VALIDATE_ASSERT#683 Extract
ArenaAllocateRawinternal helper;Allocatecalls it and zeroes; newAllocateNoZeroskips 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 NDEBUGfree-list scan detects double-free before inserting