quick C++ memory question
When a pointer is deleted, is the memory it is pointing to only returned to the heap or is it also nulled too? Thx
CPPRULZ
Junior Poster in Training
91 posts since Aug 2008
Reputation Points: 10
Solved Threads: 0
Who knows, that's for the implementation to decide.
- in release mode, it's typically back in the heap untouched.
- in debug mode, it could be filled with some specific pattern to mark "deleted data", and perhaps held in a "pending" list for a while. Specifically to assist with spotting any "use after free" errors in the code.
Salem
Posting Sage
11,531 posts since Dec 2005
Reputation Points: 5,862
Solved Threads: 953