|
@@ -5,7 +5,7 @@
|
|
#ifdef HAVE_LOCKS
|
|
#ifdef HAVE_LOCKS
|
|
#include "posix_lock.h"
|
|
#include "posix_lock.h"
|
|
#endif
|
|
#endif
|
|
-#include "dmm_init.h"
|
|
+#include <dmmlib/initialize_allocator.h>
|
|
#include "other.h"
|
|
#include "other.h"
|
|
#include "sys_alloc.h"
|
|
#include "sys_alloc.h"
|
|
#include "block_header.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
|
|
#ifndef WITH_MEMORY_SPACE_AWARENESS
|
|
|
|
|
|
-
|
|
+
|
|
if(allocator == NULL) {
|
|
if(allocator == NULL) {
|
|
allocator = &systemallocator;
|
|
allocator = &systemallocator;
|
|
if(allocator->initialized != true) {
|
|
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));
|
|
fixed_list_id = map_size_to_list(heap, req_padding(size));
|
|
|
|
|
|
-
|
|
+
|
|
if(fixed_list_id != -1) {
|
|
if(fixed_list_id != -1) {
|
|
current_maptable_node = heap->maptable_head;
|
|
current_maptable_node = heap->maptable_head;
|
|
-
|
|
+
|
|
if(fixed_list_id != 0) {
|
|
if(fixed_list_id != 0) {
|
|
for(i = 1; i < fixed_list_id; i++) {
|
|
for(i = 1; i < fixed_list_id; i++) {
|
|
current_maptable_node = current_maptable_node->next;
|
|
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) {
|
|
if(ptr == NULL) {
|
|
|
|
|
|
-
|
|
+
|
|
for(current_block = heap->free_list_head; current_block != NULL;
|
|
for(current_block = heap->free_list_head; current_block != NULL;
|
|
current_block = get_next(current_block)) {
|
|
current_block = get_next(current_block)) {
|
|
if(get_size(current_block) >= size) {
|
|
if(get_size(current_block) >= size) {
|
|
if(current_block == heap->free_list_head) {
|
|
if(current_block == heap->free_list_head) {
|
|
- heap->free_list_head = get_next(ptr);
|
|
+ heap->free_list_head = get_next(current_block);
|
|
} else {
|
|
} else {
|
|
set_next(previous_block, get_next(current_block));
|
|
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);
|
|
set_requested_size(ptr, size);
|
|
mark_used(ptr);
|
|
mark_used(ptr);
|
|
|
|
|
|
-
|
|
+
|
|
set_next(ptr, heap->used_blocks_head);
|
|
set_next(ptr, heap->used_blocks_head);
|
|
heap->used_blocks_head = ptr;
|
|
heap->used_blocks_head = ptr;
|
|
|
|
|
|
-
|
|
+
|
|
|
|
|
|
heap->dmm_stats.live_objects += 1;
|
|
heap->dmm_stats.live_objects += 1;
|
|
heap->dmm_stats.num_malloc += 1;
|
|
heap->dmm_stats.num_malloc += 1;
|
|
|
|
|
|
-
|
|
+
|
|
|
|
|
|
|
|
|
|
}
|
|
}
|
|
@@ -100,9 +100,10 @@ void * custom_ahmalloc(allocator_t* allocator, heap_t* heap, size_t size) {
|
|
ptr = sys_alloc(allocator, heap, size);
|
|
ptr = sys_alloc(allocator, heap, size);
|
|
}
|
|
}
|
|
|
|
|
|
-
|
|
+
|
|
-
|
|
+ * malloc's has been served already
|
|
-
|
|
+ */
|
|
|
|
+
|
|
if(heap->dmm_stats.num_malloc % 50) {
|
|
if(heap->dmm_stats.num_malloc % 50) {
|
|
malloc_state_refresh(heap);
|
|
malloc_state_refresh(heap);
|
|
}
|
|
}
|