[Freeciv-Dev] Re: (PR#15126) patch: fc_free macro
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
<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
- [Freeciv-Dev] Re: (PR#15126) patch: fc_free macro, Jason Short, 2006/01/10
- [Freeciv-Dev] (PR#15126) patch: fc_free macro, Christian Prochaska, 2006/01/10
- [Freeciv-Dev] Re: (PR#15126) patch: fc_free macro, Jason Short, 2006/01/10
- [Freeciv-Dev] (PR#15126) patch: fc_free macro, Christian Prochaska, 2006/01/10
- [Freeciv-Dev] Re: (PR#15126) patch: fc_free macro,
Jason Short <=
- [Freeciv-Dev] (PR#15126) patch: fc_free macro, Christian Prochaska, 2006/01/11
- [Freeciv-Dev] Re: (PR#15126) patch: fc_free macro, Jason Short, 2006/01/11
- [Freeciv-Dev] (PR#15126) patch: fc_free macro, Christian Prochaska, 2006/01/11
- [Freeciv-Dev] Re: (PR#15126) patch: fc_free macro, Jason Short, 2006/01/11
- [Freeciv-Dev] (PR#15126) patch: fc_free macro, Christian Prochaska, 2006/01/11
|
|