previous | start | next

The find_fit function

The find_fit function uses 3 auxillary helpers:

    1   static void *find_fit(size_t size)
    2   {
    3     void *bp;
    4   
    5     /* Find the first free block big enough */
    6     for(bp = heap_listp; GET_SIZE(HDRP(bp)) > 0; bp = NEXT_BLKP(bp)) {
    7       if (!GET_ALLOC(HDRP(bp)) && (asize <= GET_SIZE(HDRP(bp))) ) {
    8         return bp;
    9       }
   10     }
   11     return NULL; // No free block big enough
   12   }
   13   


previous | start | next