Browse Source

The block to be free'd has to be removed from the used blocks list of the heap.

Ioannis Koutras 13 years ago
parent
commit
bcb8a5effc
1 changed files with 4 additions and 1 deletions
  1. 4 1
      custom_free.c

+ 4 - 1
custom_free.c

@@ -11,12 +11,15 @@ void custom_free(heap_t* heap, void *ptr) {
     maptable_node_t *current_maptable_node;
 
     size = get_size(ptr);
-    fixed_list_id = map_size_to_list(heap, size);
 
 #ifdef HAVE_LOCKS	
     posix_lock(heap);
 #endif /* HAVE_LOCKS */
 
+    remove_block(ptr, heap->used_blocks_head);
+
+    fixed_list_id = map_size_to_list(heap, size);
+
     if(fixed_list_id != -1) {
         current_maptable_node = heap->maptable_head;		
         if(fixed_list_id == 0) {