Merged current commit
commit
0074f194a9
11
mm.c
11
mm.c
|
@ -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. O’Hallaron. Computer Systems: A Programmer’s Perspective.3rd Edition, Pearson, 2003. */
|
||||
static void* find_fit(size_t asize)
|
||||
|
|
Loading…
Reference in New Issue