Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 1) Take care of testcases
- Make sure the size+metadata is not too big
- 2) If this is the first time function is called, make sure to initialize the heap
- 3) See if there's a memory segment that's in the free list for the request. If the size is perfect, use that block and return from function.
- 4) Search for the largest block in the free list. If a larger piece exists, split it into 2 pieces and put it in the appropriate index of freelist. then recursively call my_malloc again.
- 5) If a larger piece does not exists, get a larger piece from sbrk, put the piece into the free list and recursively call my_malloc.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement