|
@@ -5,7 +5,7 @@
|
|
|
#ifdef HAVE_LOCKS
|
|
|
#include "posix_lock.h"
|
|
|
#endif /* HAVE_LOCKS */
|
|
|
-#include "dmm_init.h"
|
|
|
+#include <dmmlib/initialize_allocator.h>
|
|
|
#include "other.h"
|
|
|
#include "sys_alloc.h"
|
|
|
#include "block_header.h"
|
|
@@ -19,7 +19,7 @@ void * custom_ahmalloc(allocator_t* allocator, heap_t* heap, size_t size) {
|
|
|
|
|
|
#ifndef WITH_MEMORY_SPACE_AWARENESS
|
|
|
|
|
|
- // Go to the system allocator if none was given
|
|
|
+ /* Go to the system allocator if none was given */
|
|
|
if(allocator == NULL) {
|
|
|
allocator = &systemallocator;
|
|
|
if(allocator->initialized != true) {
|
|
@@ -43,10 +43,10 @@ void * custom_ahmalloc(allocator_t* allocator, heap_t* heap, size_t size) {
|
|
|
|
|
|
fixed_list_id = map_size_to_list(heap, req_padding(size));
|
|
|
|
|
|
- // If a fixed list is found, do a first fit
|
|
|
+ /* If a fixed list is found, do a first fit */
|
|
|
if(fixed_list_id != -1) {
|
|
|
current_maptable_node = heap->maptable_head;
|
|
|
- // traverse through the maptable node list
|
|
|
+ /* traverse through the maptable node list */
|
|
|
if(fixed_list_id != 0) {
|
|
|
for(i = 1; i < fixed_list_id; i++) {
|
|
|
current_maptable_node = current_maptable_node->next;
|
|
@@ -60,12 +60,12 @@ void * custom_ahmalloc(allocator_t* allocator, heap_t* heap, size_t size) {
|
|
|
|
|
|
if(ptr == NULL) {
|
|
|
|
|
|
- // first fit from free list
|
|
|
+ /* first fit from free list */
|
|
|
for(current_block = heap->free_list_head; current_block != NULL;
|
|
|
current_block = get_next(current_block)) {
|
|
|
if(get_size(current_block) >= size) {
|
|
|
if(current_block == heap->free_list_head) {
|
|
|
- heap->free_list_head = get_next(ptr);
|
|
|
+ heap->free_list_head = get_next(current_block);
|
|
|
} else {
|
|
|
set_next(previous_block, get_next(current_block));
|
|
|
}
|
|
@@ -82,16 +82,16 @@ void * custom_ahmalloc(allocator_t* allocator, heap_t* heap, size_t size) {
|
|
|
set_requested_size(ptr, size);
|
|
|
mark_used(ptr);
|
|
|
|
|
|
- // Update the used blocks list
|
|
|
+ /* 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;
|
|
|
|
|
|
- // End of Stats
|
|
|
+ /* End of Stats */
|
|
|
/* FIXME To be refactored - END */
|
|
|
|
|
|
}
|
|
@@ -100,9 +100,10 @@ void * custom_ahmalloc(allocator_t* allocator, heap_t* heap, size_t size) {
|
|
|
ptr = sys_alloc(allocator, heap, size);
|
|
|
}
|
|
|
|
|
|
- // Refresh the state of the heap allocator if a certain number of
|
|
|
- // malloc's has been served already
|
|
|
- // TODO Define 50 as a constant
|
|
|
+ /* Refresh the state of the heap allocator if a certain number of
|
|
|
+ * malloc's has been served already
|
|
|
+ */
|
|
|
+ /* TODO Define 50 as a constant */
|
|
|
if(heap->dmm_stats.num_malloc % 50) {
|
|
|
malloc_state_refresh(heap);
|
|
|
}
|