When delete [] pointer works, why can't you get the size of the array pointed to?

Viewed 314

A common way to use a heap-allocated array is:

SomeType * arr = new SomeType[15454];
//... somewhere else 
delete [] arr;

In order to do delete [] arr the C runtime has to know the length of the memory buffer associated with the pointer. Am I right?

So in principle it should be possible to access the information somehow? Could it be accessed using some library? I'm just wondering. I understand that it is not a core part of the language so it would be platform dependent.

3 Answers
Related