Try to merge tail with next block when splitting

When splitting a memory block, check if the next block is free.
If it is, then just extend it upwards instead of creating a new block.
This fixes a bug where when shrinking existing allocations would result in irreversible free space fragmentation.

When testing on the host, test all the poisoning configurations.
This commit is contained in:
Deomid Ryabkov
2018-03-22 14:58:20 +00:00
committed by Angus Gratton
parent 393f3da37c
commit 4b7eb1792e
6 changed files with 221 additions and 79 deletions

View File

@@ -244,6 +244,8 @@ void *multi_heap_realloc(multi_heap_handle_t heap, void *p, size_t size)
place.)
For now we just malloc a new buffer, copy, and free. :|
Note: If this ever changes, multi_heap defrag realloc test should be enabled.
*/
size_t orig_alloc_size = head->alloc_size;