heap_allocator icon indicating copy to clipboard operation
heap_allocator copied to clipboard

memory chunk cannot be merged when being freed

Open byeyear opened this issue 5 years ago • 0 comments

On line 71 in heap.c of current version, when the node being freed is the start of the heap, we still need to check whether it can be merged with its next chunk. For example:

p = heap_alloc(heap, 100); heap_free(heap, p);

After this 2 lines, the whole heap is still splitted into 2 free chunks, but the 2 free chunks should be merged into 1.

byeyear avatar Sep 20 '20 00:09 byeyear