title: C Memory Management in Embedded Systems
body: <p>I have to use c/asm to create a memory management system since malloc/free don't yet exist. I <strong>need</strong> to have malloc/free!</p>
  
  <p>I was thinking of using the memory stack as the space for the memory, but this would fail because when the stack pointer shrinks, ugly things happen with the allocated space.</p>
  
  <p><strong>1) Where</strong> would memory be allocated? If I place it randomly in the middle of the Heap/Stack and the Heap/Stack expands, there will be conflicts with allocated space!</p>
  
  <p><strong>12 What</strong> Is the simplest/cleanest solution for memory management? These are the only options I've researched:</p>
  
  <ul>
  <li>A memory stack where malloc grows the stack and free(p) shrinks the stack by shifting [p..stack_pointer] (this would invalidate the shifted memory addresses though...).</li>
  <li>A linked list (Memory Pool) with a variable-size chunk of memory. However I don't know <strong>where</strong> to place this in memory... should the linked list be a "global" variable, or "static"?</li>
  </ul>
  
  <p>Thanks!</p>