Pointer Memory allocation

This tip submitted by Krishnamoorthi on 2005-12-18 01:38:56. It has been viewed 21915 times.
Rating of 5.5 with 189 votes

When ever you deallocate the memory reset the pointer to NULL to make sure that you do not use a dangling pointer. For example:


Now if you try to use Session, then it will crash your program immediately, rather than using invalid memory, which will cause very hard-to-find problems.

More tips

Help your fellow programmers! Add a tip!