Quellcode durchsuchen

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

Ioannis Koutras vor 13 Jahren
Ursprung
Commit
bcb8a5effc
1 geänderte Dateien mit 4 neuen und 1 gelöschten Zeilen
  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) {