Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Oracle Database Foundations Technology Fundamentals For IT Success

Authors: Bob Bryla

1st Edition

0782143725, 9780782143720

More Books

Students also viewed these Databases questions

Question

LO23.2 Discuss the extent and sources of income inequality.

Answered: 1 week ago