title: Where do malloc() and free() store allocated sizes and addresses?
body: <p>Where do <code>malloc()</code> and <code>free()</code> store the allocated addresses and their sizes (Linux GCC)? I've read that some implementations store them somewhere before the actual allocated memory, but I could not confirm that in my tests.</p>
  
  <p>The background, maybe someone has another tip for this:</p>
  
  <p>I'm experimenting a little bit with analyzing the heap memory of a process in order to determine the current value of a string in the other process.
  Accessing the process heap memory and strolling through it is no problem. However, because the value of the string changes and the process allocates a new part of the memory each time, the string's address changes. Because the string has a fixed format it's still easy to find, but after a few changes the old versions of the string are still in the heap memory (probably freed, but still not reused / overwritten) and thus I'm not able to tell which string is the current one.</p>
  
  <p>So, in order to still find the current one I want to check if a string I find in the memory is still used by comparing its address against the addresses <code>malloc()</code> and <code>free()</code> know about.</p>
  
  <p>ciao,
  Elmar</p>