|
@@ -9,6 +9,7 @@
|
|
#include <dmmlib/initialize_allocator.h>
|
|
#include <dmmlib/initialize_allocator.h>
|
|
#include "other.h"
|
|
#include "other.h"
|
|
#include "sll/search_on_fixed.h"
|
|
#include "sll/search_on_fixed.h"
|
|
|
|
+#include "sll/best_fit_on_freelist.h"
|
|
#include "sys_alloc.h"
|
|
#include "sys_alloc.h"
|
|
#include "block_header.h"
|
|
#include "block_header.h"
|
|
#include "dmm_adaptor.h"
|
|
#include "dmm_adaptor.h"
|
|
@@ -16,7 +17,6 @@
|
|
void * custom_ahmalloc(allocator_t* allocator, heap_t* heap, size_t size) {
|
|
void * custom_ahmalloc(allocator_t* allocator, heap_t* heap, size_t size) {
|
|
void *ptr;
|
|
void *ptr;
|
|
int heap_id;
|
|
int heap_id;
|
|
- void *current_block, *previous_block;
|
|
|
|
#if defined (SPLITTING_FIXED) || defined (SPLITTING_VARIABLE)
|
|
#if defined (SPLITTING_FIXED) || defined (SPLITTING_VARIABLE)
|
|
size_t new_size;
|
|
size_t new_size;
|
|
size_t min_split_size;
|
|
size_t min_split_size;
|
|
@@ -40,7 +40,6 @@ void * custom_ahmalloc(allocator_t* allocator, heap_t* heap, size_t size) {
|
|
#endif /* WITH_MEMORY_SPACE_AWARENESS */
|
|
#endif /* WITH_MEMORY_SPACE_AWARENESS */
|
|
|
|
|
|
ptr = NULL;
|
|
ptr = NULL;
|
|
- previous_block = NULL;
|
|
|
|
|
|
|
|
#ifdef HAVE_LOCKS
|
|
#ifdef HAVE_LOCKS
|
|
posix_lock(heap);
|
|
posix_lock(heap);
|
|
@@ -49,21 +48,7 @@ void * custom_ahmalloc(allocator_t* allocator, heap_t* heap, size_t size) {
|
|
ptr = search_on_fixed(heap, req_padding(size));
|
|
ptr = search_on_fixed(heap, req_padding(size));
|
|
|
|
|
|
if(ptr == NULL) {
|
|
if(ptr == NULL) {
|
|
-
|
|
|
|
- /* 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(current_block);
|
|
|
|
- } else {
|
|
|
|
- set_next(previous_block, get_next(current_block));
|
|
|
|
- }
|
|
|
|
- ptr = current_block;
|
|
|
|
- break;
|
|
|
|
- }
|
|
|
|
- previous_block = current_block;
|
|
|
|
- }
|
|
|
|
|
|
+ ptr = best_fit_on_freelist(heap, size);
|
|
}
|
|
}
|
|
|
|
|
|
if(ptr != NULL) {
|
|
if(ptr != NULL) {
|