Browse Source

Reset the allocator's border pointer in case it is next_block and will be coalesced with the current block.

Ioannis Koutras 13 years ago
parent
commit
d301b9ca3d
1 changed files with 6 additions and 0 deletions
  1. 6 0
      src/custom_free.c

+ 6 - 0
src/custom_free.c

@@ -129,6 +129,9 @@ void custom_ahfree(allocator_t *allocator, heap_t* heap, void *ptr) {
     if(three_blocks_size <= max_coal_size) {
         ptr = coalesce(allocator, heap, ptr, three_blocks_size);
         remove_block_from_lists(&next_block, heap);
+        if(allocator->border_ptr == next_block) {
+            allocator->border_ptr = ptr;
+        }
         coalesced = true;
         size = three_blocks_size;
     } else {
@@ -140,6 +143,9 @@ void custom_ahfree(allocator_t *allocator, heap_t* heap, void *ptr) {
             if(current_next_size <= max_coal_size) {
                 set_size_and_free(allocator, ptr, current_next_size);
                 remove_block_from_lists(&next_block, heap);
+                if(allocator->border_ptr == next_block) {
+                    allocator->border_ptr = ptr;
+                }
             } else {
                 mark_free(allocator, ptr);
             }