Re: if (blah) ...

From: Rich Chiavaroli (rchiav@frontiernet.net)
Date: 08/19/99


On Thu, 19 Aug 1999, Peter Ajamian wrote:

Ceartainly there are several places where it frees memory, then sets the pointer
to null, but where does it then turn around and base an if statement on the value
of the pointer which was just set to null as in the following line from above...?

>> > if (blah) printf("This is still printed.\n");

Regards,


Peter

I think you missed the point of the if check.. the point was that freeing
a pointer doesn't mean that the variable that held the pointer changed. It
just means that the memory was freed. Hence you could mistakenly, at a
later time, perform an if check on the pointer variable, have it be true
but the memory refrenced by that pointer is not useable.. or shouldn't be
used because it's not reserved for your purpose anymore. So in the
example, all they were trying to say is that you need to set your pointer
variable to NULL after you free it if you are going to check for it's
existance at a later time...

Hope that makes things clearer...

Rich


     +------------------------------------------------------------+
     | 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