Question: How do I make these 2 macros into a function? /* Given block ptr bp, compute address of next and previous free blocks */ #define
How do I make these 2 macros into a function?
/* Given block ptr bp, compute address of next and previous free blocks */
#define NEXT_FREEP(bp)(*(void **)(bp + 16))
#define PREV_FREEP(bp)(*(void **)(bp))
here bp is a block pointer (void* bp)
I want to have this macro as a function so I can call it like this
static char *free_listp = 0;/* Pointer to the first free block */
static void insertAtFront(void *bp){
NEXT_FREEP(bp) = free_listp; //Sets next ptr to start of free list
PREV_FREEP(free_listp) = bp; //Sets current's prev to new block
PREV_FREEP(bp) = NULL; // Sets prev pointer to NULL
free_listp = bp; // Sets start of free list as new block
}
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
