How does delete[] know the size of an array?
<blockquote>
  <p><strong>Possible Duplicates:</strong><br />
  <a href="http://stackoverflow.com/questions/377178/how-does-the-standard-new-operator-work-in-c">How does the standard new operator work in c++?</a><br />
  <a href="http://stackoverflow.com/questions/197675/how-does-delete-know-the-size-of-the-operand-array">How does delete[] &#8220;know&#8221; the size of the operand array?</a>  </p>
</blockquote>

<p>Dupe of <a href="http://stackoverflow.com/questions/197675/how-does-delete-know-the-size-of-the-operand-array">http://stackoverflow.com/questions/197675/how-does-delete-know-the-size-of-the-operand-array</a></p>

<p>I am curious how delete[] figures out the size of the allocated memory. When I do something like:</p>

<pre><code>int* table = new int[5];
delete[] table;
</code></pre>

<p>I understand that the memory of the table is freed. But what would happen if I reassigned the pointer to some different table. </p>

<pre><code>int* table = new [5];
int* table2 = new [9];
table = table2;
delete[] table;
</code></pre>

<p>Will I free a table of the size 5 or 9? I am interested in how new[] and delete[] share information about their size. Or maybe I am missing something essential here.</p>
