Quote:
Originally Posted by rraagg
Hi All
if i allocated memory using malloc
and then place data into it,
freeing it up using free() just marks the memory as free? ie it does not clear
the data in the memory, I could still use the pointer to get the data. Is this correct?
|
It's correct but dangerous. free() tells the OS that you are done with the block of memory and it may re-use it for something else. If you still have a pointer to the freed memory it may contain your data now, but your data could be erased or corrupted at any time, even in the middle of one of your statements.