Skip to content

Commit

Permalink
Cleanup smartGarbage
Browse files Browse the repository at this point in the history
  • Loading branch information
SeekyCt committed Jan 10, 2025
1 parent e651ef1 commit 6a6b27e
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions src/memory.c
Original file line number Diff line number Diff line change
Expand Up @@ -506,7 +506,7 @@ void smartGarbage()
{
sysWaitDrawSync();

// Update space at the start of the heap (redundant? alloc & free do this whenever it changes)
// Update space at the start of the heap
if (swp->allocatedStart != 0)
swp->heapStartSpace = 0;
else
Expand All @@ -515,7 +515,7 @@ void smartGarbage()
// Move all allocations closer together if possible
SmartAllocation * prevAllocation = NULL;
void * space = swp->heapStart;
for (SmartAllocation * curAllocation = swp->allocatedStart; curAllocation; curAllocation = curAllocation->next)
for (SmartAllocation * curAllocation = swp->allocatedStart; curAllocation; prevAllocation = curAllocation, curAllocation = curAllocation->next)
{
// If this allocation can be moved forwards
if (curAllocation->data != space)
Expand All @@ -532,10 +532,10 @@ void smartGarbage()
else
swp->heapStartSpace = (u32) curAllocation->data - (u32) space;

// Do the exact things the goto skips anyway
// Do the exact things the continue skips anyway
space = (void *) ((u32)curAllocation->data + curAllocation->size);
curAllocation->spaceAfter = 0;
goto LB_801a6c64;
continue;
}
else
{
Expand All @@ -553,9 +553,6 @@ void smartGarbage()
// Assume there'll be no space after this, will be updated by the allocation after if this ends up being not true
curAllocation->spaceAfter = 0;
space = (void *) ((u32)curAllocation->data + curAllocation->size);

LB_801a6c64:
prevAllocation = curAllocation;
}

// Update spaceAfter of final allocation, since assumption it'd be 0 wasn't true
Expand Down

0 comments on commit 6a6b27e

Please sign in to comment.