All pastes #252766 Raw Edit

Stuff

public c v1 · immutable
#252766 ·published 2006-11-19 23:18 UTC
rendered paste body
static void *next_fit(size_t asize){    void *bp  = last_block;    int wraps = 0;    while(GET_SIZE(HDRP(bp)) > 0){        if(wraps > 0 && bp == last_block) // We went through the whole thing                return NULL;        if(!GET_ALLOC(HDRP(bp) && (asize <= GET_SIZE(HDRP(bp))) {                last_block = bp;                return bp;        }       bp = NEXT_BLKP(bp);       if(GET_SIZE(HDRP(bp)) <= 0){        // We hit the end, need wrap around                bp = heap_listp;                wraps++;       } // end if    } // end while} // end next_fit