|
@@ -76,6 +76,7 @@ void custom_ahfree(allocator_t *allocator, heap_t* heap, void *ptr) {
|
|
|
mark_free(ptr);
|
|
|
coalesced = false;
|
|
|
}
|
|
|
+
|
|
|
}
|
|
|
} else {
|
|
|
mark_free(ptr);
|
|
@@ -93,37 +94,21 @@ void custom_ahfree(allocator_t *allocator, heap_t* heap, void *ptr) {
|
|
|
current_maptable_node = current_maptable_node->next;
|
|
|
}
|
|
|
}
|
|
|
-#ifdef BLOCKS_IN_DLL
|
|
|
- set_previous(ptr, NULL);
|
|
|
- set_previous(current_maptable_node->fixed_list_head, ptr);
|
|
|
-#endif /* BLOCKS_IN_DLL */
|
|
|
- set_next(ptr, current_maptable_node->fixed_list_head);
|
|
|
- current_maptable_node->fixed_list_head = ptr;
|
|
|
+ push_block(ptr, current_maptable_node->fixed_list_head);
|
|
|
} else { /* put it in the free list */
|
|
|
#if defined (COALESCING_FIXED) || defined (COALESCING_VARIABLE)
|
|
|
- /* If the block is coalesced, there is no need to add it to the free
|
|
|
- * list as there is already an entry of the old block
|
|
|
+ /* The block should be added to the free list only if it is not
|
|
|
+ * coalesced
|
|
|
*/
|
|
|
if(!coalesced) {
|
|
|
-#ifdef BLOCKS_IN_DLL
|
|
|
- set_previous(heap->free_list_head, ptr);
|
|
|
- set_previous(ptr, NULL);
|
|
|
-#endif /* BLOCKS_IN_DLL */
|
|
|
- set_next(ptr, heap->free_list_head);
|
|
|
- heap->free_list_head = ptr;
|
|
|
+ push_block(ptr, heap->free_list_head);
|
|
|
}
|
|
|
#else
|
|
|
-#ifdef BLOCKS_IN_DLL
|
|
|
- set_previous(heap->free_list_head, ptr);
|
|
|
- set_previous(ptr, NULL);
|
|
|
-#endif /* BLOCKS_IN_DLL */
|
|
|
- set_next(ptr, heap->free_list_head);
|
|
|
- heap->free_list_head = ptr;
|
|
|
+ push_block(ptr, heap->free_list_head);
|
|
|
#endif /* COALESCING_FIXED || COALESCING_VARIABLE */
|
|
|
}
|
|
|
|
|
|
- /* Begin of Stats */
|
|
|
-
|
|
|
+ /* Update Stats */
|
|
|
heap->dmm_stats.live_objects -= 1;
|
|
|
heap->dmm_stats.num_free += 1;
|
|
|
|