Question: in C programming language create a my_malloc and my_free which implement a simple memory allocator using a linked list and a first-fit allocation scheme. Your

in C programming language

create a my_malloc and my_free which implement a simple memory allocator using a linked list and a first-fit allocation scheme.

Your my_malloc function will: Round up the size of the requested allocation to a certain size (I gave you this) Try to find a block to reuse, using first-fit allocation If it found a block, and that block can be split into two smaller blocks, do so If it couldnt find a block, expand the heap by moving the break with sbrk() Mark it as used Return the pointer to the data part (after the header)

Your my_free function will: Figure out the pointer to the header Mark the block free Coalesce it with any neighboring blocks on either side If its the last block on the heap, contract the heap by moving the break with sbrk()

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!