diff options
author | Andreas Kling <awesomekling@gmail.com> | 2019-05-02 16:35:57 +0200 |
---|---|---|
committer | Andreas Kling <awesomekling@gmail.com> | 2019-05-02 16:35:57 +0200 |
commit | 60023ff70ba34bc8c8d31d483b2a1e6db51af1a4 (patch) | |
tree | b25b89b892564c1ca7320668d6d00b38f84dedb5 | |
parent | 658fff195c282393c45f1be81a0b0dcd6977b911 (diff) | |
download | serenity-60023ff70ba34bc8c8d31d483b2a1e6db51af1a4.zip |
LibC: free() should move kept empty ChunkedBlocks to the end of the list.
This ensures that we continue allocating from partially-used blocks until
they are full.
-rw-r--r-- | LibC/malloc.cpp | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/LibC/malloc.cpp b/LibC/malloc.cpp index b7204d0d8f..38feddd216 100644 --- a/LibC/malloc.cpp +++ b/LibC/malloc.cpp @@ -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 |