Added new function add_free()

master
anna_schlittenhardt 2021-01-24 18:08:02 +01:00
parent 85abbe732b
commit 27e75d248b
1 changed files with 8 additions and 1 deletions

9
mm.c
View File

@ -130,6 +130,12 @@ static void* extend_heap(size_t words);
////////////////////////////////////////////////////////////////////////////////
/////////////////////////////// HELPER FUNCTIONS ///////////////////////////////
////////////////////////////////////////////////////////////////////////////////
static void add_free(void* ptr, size_t size)
{
int szClass = getSzClass(size);
void* classPtr = seg_list[szClass];
}
static void place(void *bp, size_t asize)
{
size_t csize = GET_SIZE(HDRP(bp));
@ -152,7 +158,7 @@ static int getSzClass(size_t asize) {
return i;
}
}
return LISTSIZE;
return LISTSIZE-1;
}
static void* best_fit(void* ptr, size_t asize) {
@ -313,6 +319,7 @@ void *mm_malloc(size_t size)
void mm_free(void *ptr)
{
size_t size = GET_SIZE(HDRP(ptr));
add_free(ptr, size);
PUT(HDRP(ptr), PACK(size, 0));
PUT(FTRP(ptr), PACK(size, 0));