I am curious how delete[] figures out the size of the allocated memory. When I do something like:
int* table = new int[5];
delete[] table;
I understand that the memory of the table is freed. But what would happen if I reassigned the pointer to some different table.
int* table = new [5];
int* table2 = new [9];
table = table2;
delete[] table;
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.