Consider an implicit-list based allocator and memory architecture with the follo
ID: 3909448 • Letter: C
Question
Consider an implicit-list based allocator and memory architecture with the following properties: words are 4 bytes large (ints and addresses are word-sized) memory blocks are double-word (8-byte) aligned each block has a header and footer word, which stores its size and an allocated bit (0 for free, 1 for allocated) The five functions that follow are defined to facilitate the implementation of free. The behavior of each function is explained in the comment that precedes it. Circle the letter next to the line of code that correctly completes each functionExplanation / Answer
Below is the solution:
void *footer(void *p)
{
void *ptr;
ptr = (char *)p + size(header(p)) -8;
return ptr;
}
Answer: (c) ptr = (int *)p + size(header(p)) -2;
int allocated(void *hp)
{
int result;
result = *(int *)hp & 1
return result;
}
Answer: (a) result = *(int *)hp & 1
void *prev(void *hp)
{
void *ptr;
ptr = (int *)hp - size(hp);
return ptr;
}
Answer: (a) ptr = (char *)hp - size((char *)hp - 4);