Given:
struct DBRESULTS *pDBResults;
pDBResults = (struct DBRESULTS *)malloc(sizeof(struct DBRESULTS))
if (pDBResults != NULL)
free (pDBResults);
The test for whether to free or not will pass regardless of whether the memory has already been freed. In other words, I do this when I'm finished, but I also have this as the program is exiting in case there was a problem and the program is shutting down outside the normal sequence. When the normal sequence IS followed, the first occurance frees the memory, and the second occurance tries to and gives an error (because it is attempting to free a pointer already freed).
How can I test the pointer to tell whether it has already been freed or not?