Re: hmmm.... db.c:free_char()

From: Mark A. Heilpern (heilpern@MINDSPRING.COM)
Date: 08/07/98


At 07:52 AM 8/7/98 -0400, you wrote:
>> >At the very end of this function, is there any reason not to do a ch=NULL;
>> >right have the free(ch); call?  I think this might be a nice way to ensure
>> >consistancy.  But for that DT and fast aggr problem, you need to check to
>> >see if(ch && ch->in_room)
>
>since everyone explained why it wouldn't work, but didn't provide a
>solution, here's one..just make a macro like:
>
>#define FREE(var)       do {            \
>                          free(var);    \
>                          var = NULL;   \
>                        } while (0)
>
>and replace all free() calls with FREE()..

What kind of drugs are you on? If the parameter being passed into the FREE()
macro is STILL a local variable, then the effect of nulling it out is STILL
zero.
It doesn't matter if it's done as a macro or code you typed in.

On a side note, why would you ever want to enclose code within a "do { }
while (0);"
block? If you've a legitimate need for a sub-block of code, such as to
introduce
some very temporary local variables, just use your braces and forget the
do/while.


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



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