Complete.Org: Mailing Lists: Archives: freeciv-dev: January 2006:
[Freeciv-Dev] Re: (PR#15126) patch: fc_free macro
Home

[Freeciv-Dev] Re: (PR#15126) patch: fc_free macro

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: cp.ml.freeciv.dev@xxxxxxxxxxxxxx
Subject: [Freeciv-Dev] Re: (PR#15126) patch: fc_free macro
From: "Jason Short" <jdorje@xxxxxxxxxxxxxxxxxxxxx>
Date: Tue, 10 Jan 2006 14:15:53 -0800
Reply-to: bugs@xxxxxxxxxxx

<URL: http://bugs.freeciv.org/Ticket/Display.html?id=15126 >

Christian Prochaska wrote:
> <URL: http://bugs.freeciv.org/Ticket/Display.html?id=15126 >
> 
>>[jdorje - Di 10. Jan 2006, 20:10:08]:
>>
>>The do...while construct is to make it act like a single statement.  For 
>>instance in
>>
>>   if (x)
>>     FREE(y);
>>   else
>>     FREE(z);
>>
>>without the do...while bits the code is quite a bit different, even if 
>>you use brackets in the FREE (as your original did).
>>
>>-jason
>>
> 
> 
> Ahh, I see. I falsely assumed the problem was that the macro definition
> looks like a function, but actually you meant the lower-case name makes
> it look like a normal function in the code which uses the macro.

Yes.  Note you can't write fc_free as a function.  But you could write:

   void fc_free(void **ptr)
   {
     free(ptr);
     *ptr = NULL;
   }

Also note the do...while construct shouldn't matter in code that uses 
"proper" freeciv style (that is, overuse of brackets).  But it can't hurt.

-jason





[Prev in Thread] Current Thread [Next in Thread]