Explorar el Código

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

Ioannis Koutras hace 14 años
padre
commit
bcb8a5effc
Se han modificado 1 ficheros con 4 adiciones y 1 borrados
  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) {