Monday, May 16, 2011

Pointer Memory allocation

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

free(Session);
Session=NULL;

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.