Question

If I have something like that:

char* plainText = init();
delete [] plainText;

All is working normal and the dynamic memory is marked as free.

But when I call something like this:

char* plainText = init();
deletePlainText(plainText);

Where

void deletePlainText(char *plainText)
{
   delete[] plainText;
}

The memory is not marked as free it is something like that:

+  plainText 0x005cb160 "îþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþ... char *

Is it possible to call delete operator from outer function and how?

Original Source:

http://pastebin.com/1pybC02t
http://pastebin.com/KbtfG5Cw
http://pastebin.com/NSyULHaF
Was it helpful?

Solution

If you see into the memory window in VS (address of variavle 'plainText'),it looks as follows:

0x0056BB28 ee fe ee fe ee fe ee fe ee fe ee fe ee fe fe îþîþîþîþîþîþîþîþîþîþîþîþîþîþ

This is the information from : http://en.wikipedia.org/wiki/Magic_number_%28programming%29

FEEEFEEE "Fee fee", Used by Microsoft's debug HeapFree() to mark freed heap memory. Some nearby internal bookkeeping values may have the high word set to FEEE as well.

So this indicates that your memory has been freed and now you should not use it.This magic number is Microsoft specific memory manager behavior.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top