Back To The Basics: Freeing An Array on the Heap?
So I've been programming for quite a while and I swear to God when you create an array on the heap.
Code:
float *f = new float[5];
You must, to avoid a memory leak, call:
However, if I watch the actual memory the code below appears to clean up all memory just fine does it not?
I was taught this would only delete the pointer and not the entire array, but now that I think about it isn't f's allocation size of 20 bytes just stored in the heap table and when a delete is called it just pulls that # of 20 off the heap table and deletes it?
First call is just calling malloc(20) and the second is just freeing that 20 bytes no matter which delete call is made? eh? Am I wrong here? What is the difference between delete [] and delete again?
(If anyone is wondering I'm overriding the new and delete calls to write my own at which point I encountered this seemingly basic issue)