Re: if (blah) ...

From: Chris Proctor (cjp@minotaur.labyrinth.net.au)
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:
free(blah);
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 . . .
Regards,
Chris Proctor (Deathblade, Implementor of DominiaMUD)
MUD Homepage: http://www.labyrinth.net.au/~cjp


     +------------------------------------------------------------+
     | Ensure that you have read the CircleMUD Mailing List FAQ:  |
     |  http://qsilver.queensu.ca/~fletchra/Circle/list-faq.html  |
     +------------------------------------------------------------+



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