summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Kling <awesomekling@gmail.com>2019-05-02 16:35:57 +0200
committerAndreas Kling <awesomekling@gmail.com>2019-05-02 16:35:57 +0200
commit60023ff70ba34bc8c8d31d483b2a1e6db51af1a4 (patch)
treeb25b89b892564c1ca7320668d6d00b38f84dedb5
parent658fff195c282393c45f1be81a0b0dcd6977b911 (diff)
downloadserenity-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.cpp7
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