|
@@ -76,21 +76,29 @@ void * custom_ahmalloc(allocator_t* allocator, heap_t* heap, size_t size) {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- if(ptr == NULL) {
|
|
|
|
- ptr = sys_alloc(allocator, heap, size);
|
|
|
|
- }
|
|
|
|
|
|
+ if(ptr != NULL) {
|
|
|
|
|
|
- set_requested_size(ptr, size);
|
|
|
|
- set_next(ptr, heap->used_blocks_head);
|
|
|
|
|
|
+ /* FIXME To be refactored - START */
|
|
|
|
+ set_requested_size(ptr, size);
|
|
|
|
+ mark_used(ptr);
|
|
|
|
|
|
- heap->used_blocks_head = ptr;
|
|
|
|
|
|
+ // Update the used blocks list
|
|
|
|
+ set_next(ptr, heap->used_blocks_head);
|
|
|
|
+ heap->used_blocks_head = ptr;
|
|
|
|
|
|
- // Begin of Stats
|
|
|
|
|
|
+ // Begin of Stats
|
|
|
|
|
|
- heap->dmm_stats.live_objects += 1;
|
|
|
|
- heap->dmm_stats.num_malloc += 1;
|
|
|
|
|
|
+ heap->dmm_stats.live_objects += 1;
|
|
|
|
+ heap->dmm_stats.num_malloc += 1;
|
|
|
|
|
|
- // End of Stats
|
|
|
|
|
|
+ // End of Stats
|
|
|
|
+ /* FIXME To be refactored - END */
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if(ptr == NULL) {
|
|
|
|
+ ptr = sys_alloc(allocator, heap, size);
|
|
|
|
+ }
|
|
|
|
|
|
// Refresh the state of the heap allocator if a certain number of
|
|
// Refresh the state of the heap allocator if a certain number of
|
|
// malloc's has been served already
|
|
// malloc's has been served already
|