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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started