title: How to determine the size of an allocated C buffer?
body: <p>I have a buffer and want to do a test to see if the buffer has sufficient capacity I.e. find number of elements I can add to the buffer.</p>
  
  <pre><code>char *buffer = (char *)malloc(sizeof(char) * 10);
  </code></pre>
  
  <p>Doing a </p>
  
  <pre><code>int numElements = sizeof(buffer); 
  </code></pre>
  
  <p>does not return 10, any ideas on how I can accomplish this?</p>