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; } } }