Question: Next Fit Memory Allocation in C Make your own malloc and free functions using a doubly linked list to track the nodes in the heap.

Next Fit Memory Allocation in C

Make your own malloc and free functions using a doubly linked list to track the nodes in the heap. The following struct will serve as the header for each linked list node:

typedef struct Node{

int size;

int free;

struct Node* next;

struct Node* prev;

} Node;

And three globals called, first, last, curr, that keeep track of the first allocated block on heap, final allocated block on heap, and the current position of the block that was last allocated on the heap.

Make a malloc() next fit memory allocation scheme in function: void* my_next_fit_malloc(int size). this function should allocate memory using a next fit allocation scheme. If there is no empty space in the heap allocate more using sbrk(). Use of multiple functions encouraged.

And a free() function called: void my_free(void* ptr) to dellocate memory.

Write a test file to test these my_free and my_malloc functions.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!