Skip to content

Commit

Permalink
LibC: free() should move kept empty ChunkedBlocks to the end of the l…
Browse files Browse the repository at this point in the history
…ist.

This ensures that we continue allocating from partially-used blocks until
they are full.
  • Loading branch information
awesomekling committed May 2, 2019
1 parent 658fff1 commit 60023ff
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions LibC/malloc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,13 @@ void free(void* ptr)
#ifdef MALLOC_DEBUG
dbgprintf("Keeping block %p around for size class %u\n", block, good_size);
#endif
if (allocator->blocks.tail() != block) {
#ifdef MALLOC_DEBUG
dbgprintf("Moving block %p to tail of list for size class %u\n", block, good_size);
#endif
allocator->blocks.remove(block);
allocator->blocks.append(block);
}
return;
}
#ifdef MALLOC_DEBUG
Expand Down

0 comments on commit 60023ff

Please sign in to comment.