From 5b628e7ad711c84638b693d89c696816a53e57c8 Mon Sep 17 00:00:00 2001 From: Gary Talent Date: Sat, 14 Oct 2017 12:49:30 -0500 Subject: [PATCH] Fix delete operator to move _heapIdx closer to heap start --- src/nostalgia/core/gba/mem.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/nostalgia/core/gba/mem.cpp b/src/nostalgia/core/gba/mem.cpp index 8a7fd40f..0331e456 100644 --- a/src/nostalgia/core/gba/mem.cpp +++ b/src/nostalgia/core/gba/mem.cpp @@ -87,6 +87,13 @@ void operator delete(void *ptr) { if (prev && !prev->inUse) { prev->size += current->size; prev->next = current->next; + current = prev; + } + + // if current is closer heap start than _heapIdx, _heapIdx becomes + // current + if (current > _heapIdx) { + _heapIdx = current; } } }