Advertisement
Guest User

Untitled

a guest
Apr 23rd, 2014
50
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.61 KB | None | 0 0
  1. 1) Take care of testcases
  2. Make sure the size+metadata is not too big
  3. 2) If this is the first time function is called, make sure to initialize the heap
  4.  
  5. 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.
  6.  
  7. 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.
  8.  
  9. 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