title: Implementing segregated memory storage (malloc) in C
body: <p>I'm trying to implement my own malloc using a segregated free list (using this textbook as a reference: <a href="http://csapp.cs.cmu.edu/" rel="nofollow">http://csapp.cs.cmu.edu/</a>), but I'm not sure how to start. </p>
  
  <p>I have a method, <code>malloc_init()</code> that uses <code>sbrk</code> to return a slab of memory. Within the context of my assignment, I'm not allowed to ask for more memory after this initial call, and the amount of memory I'm allowed to request is limited by <code>MAX_HEAP_SIZE</code> (set by someone else). I am thinking that I will keep an array of pointers, each of which points to a freelist of predetermined size. </p>
  
  <p>How do I set up this array after calling <code>sbrk</code>? How do I figure out how many bytes should go into each "bucket" and how the class size of each freelist? In terms of code implementation, how does one set up the array of freelist pointers? Any tips or hints would be greatly appreciated! I've looked for example code online but have not found anything satisfying. </p>