Beispiel #1
0
/*Removing a block from the free list either due to allocation or during coalascing*/
static void remove_list(void *bp){
  if (GET_PREVP(bp))
    SET_NEXTP(GET_PREVP(bp), GET_NEXTP(bp));
  else
    list_head = GET_NEXTP(bp);
  SET_PREVP(GET_NEXTP(bp), GET_PREVP(bp));
}
Beispiel #2
0
/**
 * add_free_list_lifo - add the specific block ptr to the free list, making it
 *                      the first element in the list(LIFO).
 * @param bp Pointer to the block being added to the list
 */
static void *add_free_list_lifo(void *bp)
{
    int list_no ;
 
    /*Coalesce the block*/
    bp = coalesce_block(bp);

    list_no = get_list_no(GET_SIZE(HDRP(bp)));        
    if ( GET_SEGI(seg_list,list_no) == NULL) { 
        SET_PREVP(bp, NULL);
        SET_NEXTP(bp, NULL);
    } else if ( GET_SEGI(seg_list,list_no) != NULL) {
        SET_NEXTP(bp,GET_SEGI(seg_list,list_no));
        SET_PREVP(bp,NULL);
        SET_PREVP(GET_SEGI(seg_list,list_no),bp);
    }

    /*Point next of bp to where root node was pointing*/
    /*Make root to point to new node*/
    SET_SEGI(seg_list, list_no, bp);
    return bp;
}
Beispiel #3
0
/**
 * delete_free_list - Delete a block from the free seg list
 * @param bp block to be deleted from free list
 */
static  inline void delete_free_list(void *bp)
{
    int list_no = get_list_no(GET_SIZE(HDRP(bp)));
    temp++;
    void *next = GET_NEXTP(bp);
    void *prev = GET_PREVP(bp);
    /*Handle corner case of deleting head node.*/
    if(bp == GET_SEGI(seg_list, list_no) ) {
        SET_SEGI(seg_list, list_no, next);
    }

    if(prev != NULL) {
        SET_NEXTP(prev, next);
    }

    if(next != NULL) {
        SET_PREVP(next, prev);
    }

    /*Clean Up task. Set next/prev pointers of bp to NULL*/
    SET_NEXTP(bp,NULL);
    SET_PREVP(bp,NULL);
}
Beispiel #4
0
/*Inserting a free block into the free list*/
static void insert_list(void *bp){
  SET_NEXTP(bp, list_head); 
  SET_PREVP(list_head, bp); 
  SET_PREVP(bp, NULL); 
  list_head = bp; 
}