Merged current commit

master
TuDatTr 2021-01-24 17:01:10 +01:00
commit 0074f194a9
1 changed files with 8 additions and 3 deletions

11
mm.c
View File

@ -163,12 +163,17 @@ static int getSzClass(size_t asize) {
static void* best_fit(void* ptr, size_t asize) {
unsigned long left_over = GET_SIZE(ptr) - asize;
int c = 0;
void* bestfit = ptr;
int best_left_over = GET_SIZE(ptr) - asize);
while (NXT_FREE(ptr) != NULL) {
left_over = (MIN(left_over, GET_SIZE(ptr) - asize));
left_over = GET_SIZE(ptr) - asize);
if(left_over<best_left_over){
best_left_over = left_over;
bestfit=ptr;
}
ptr = NXT_FREE(ptr);
}
return NULL;
return bestfit;
}
/* Page 856, Pearson R. Bryant D. OHallaron. Computer Systems: A Programmers Perspective.3rd Edition, Pearson, 2003. */
static void* find_fit(size_t asize)