fix: add free-list to WardenEmulator heap allocator to prevent exhaustion

The bump-pointer allocator never reused freed blocks, causing the 16 MB
emulated heap to exhaust in long sessions even when blocks were freed.

- First-fit reuse from a free-list before advancing the bump pointer
- Coalesce adjacent free blocks to limit fragmentation
- Roll back the bump pointer when the top free block reaches it
- Reset allocator state on initialize() so re-runs start clean
This commit is contained in:
Kelsi 2026-03-17 13:55:37 -07:00
parent ae40d393c3
commit 5031351736
2 changed files with 65 additions and 3 deletions

View file

@ -152,6 +152,7 @@ private:
// Memory allocation tracking
std::map<uint32_t, size_t> allocations_;
std::map<uint32_t, size_t> freeBlocks_; // free-list keyed by base address
uint32_t nextHeapAddr_;
// Hook handles for cleanup