title: Taming the malloc/free beast -- tips & tricks
body: <p>I've been using C on some projects for a master's degree but have never built production software with it. (.NET &amp; Javascript are my bread and butter.) Obviously, the need to <code>free()</code> memory that you <code>malloc()</code> is critical in C.  This is fine, well and good if you can do both in one routine.  But as programs grow, and structs deepen, keeping track of what's been <code>malloc</code>'d where and what's appropriate to free gets harder and harder.</p>
  
  <p>I've looked around on the interwebs and only found a few generic recommendations for this.  What I suspect is that some of you long-time C coders have come up with your own patterns and practices to simplify this process and keep the evil in front of you.  </p>
  
  <p>So: how do you recommend structuring your C programs to keep dynamic allocations from becoming memory leaks?  </p>