Deleting a char array from the Heap

Alright so I've written a function that returns a pointer to a char array on the heap. So my code looks something like this char *ptr = func("This is the argument being allocated to the heap"); . Then later when I call delete[], only 1 word (four bytes) are being deleted. The rest stays on the heap and I can't figure out what is wrong with it. Any help would be appreciated
ForTheReallys wrote:
only 1 word (four bytes) are being deleted. The rest stays on the heap
It is not possible for you to know this without doing something which is not allowed by the language. How are you checking this?

Note that freeing memory just marks the memory as not being used anymore so it can be reused later, maybe even by another program.
I used gdb to check this. But I was just being stupid. I assumed that because the first four bytes were 0 after they were all deleted, I assumed that this meant ONLY those bytes were deleted... duh! Haha Thanks!
Topic archived. No new replies allowed.