Re: if (blah) ...

From: Chris Proctor (
Date: 08/17/99

>It only does "this" if "blah" is true (i.e., it's not zero/NULL).  A
>negative number is non-zero, and thus counts.  "if (blah)" is not the
>proper way to check for positive integers, only for things that are not
>NULL.  Note that free() DOES not set memory back to NULL, thus:
>     free(blah);
>     if (blah) printf("This is still printed.\n");
>Will print, "This is still printed.," but the memory is NOT valid for use.

Can you then:
blah = NULL;
if (blah) printf("This is still printed.\n");

Presumably the best way is to just make sure that you don't try and do
anything with the data after you've freed it . . .
Chris Proctor (Deathblade, Implementor of DominiaMUD)
MUD Homepage:

     | Ensure that you have read the CircleMUD Mailing List FAQ:  |
     |  |

This archive was generated by hypermail 2b30 : 12/15/00 PST