#include "custom_free.h" #include "other.h" #include "posix_lock.h" void custom_free(heap_t* heap, void *ptr) { size_t size; int fixed_list_id, i; MAPTABLE_NODE *current_maptable_node; leaHdr *test; size = getSize((char *) ptr); fixed_list_id = map_size_to_list(heap, size); posix_lock(heap); if(fixed_list_id != -1) { current_maptable_node = heap->maptable_head; if(fixed_list_id == 0) { test = getHeader(ptr); test->next = current_maptable_node->fixed_list_head; //getHeader((char *) ptr)->next = current_maptable_node->fixed_list_head; current_maptable_node->fixed_list_head = ptr; } else { for(i = 1; i < fixed_list_id; i++) { current_maptable_node = current_maptable_node->next; } getHeader(ptr)->next = current_maptable_node->fixed_list_head; current_maptable_node->fixed_list_head = ptr; } } else { // put it in the free list getHeader(ptr)->next = heap->free_list_head; heap->free_list_head = getHeader(ptr); } markFree((char *) ptr); posix_unlock(heap); }