Pointer alloc size question
I realized something that I can't figure out: how do we obtain the length of some dynamic array allocated with a pointer? Considering that any pointer gives a "sizeof()" of 4 bytes, and that these 4 bytes represent an address, then where is the allocation's length stored?
As with the following, operators "new" and "delete" will know how much space they have to allocate, and how much space they will have to deallocate:
So where can we find out the information that actually tells the allocated size? I know that before "new-ing" it would be a good idea to store the length in a variable if we later want to use that length, but where is the info? Could it be possible that only the OS knows how much space that ptr uses?
ptr = new int;
delete ptr; //The function will know that "ptr" points to an array of 100 ints...