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

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

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
Subject: [Freeciv-Dev] (PR#15126) patch: fc_free macro
From: "Christian Prochaska" <>
Date: Tue, 10 Jan 2006 11:53:56 -0800
Reply-to: bugs@xxxxxxxxxxx

<URL: >

> [jdorje - Di 10. Jan 2006, 19:00:23]:
> Such a macro violates the rules of function-looking macros.  That is, it 
> looks like a function but it behaves as no function ever could.
> If we have it (code like this is used in several places) it should be 
> FC_FREE().
> -jason

The macro in gui-sdl/gui_mem.h is actually

#define FREE(ptr) do { if (ptr) free(ptr); ptr = NULL; } while(0)

So as I now understand the do {} while(0) construct is just to make it
not look like a function and thus the macro in utility/mem.h should be

#define FC_FREE(ptr) do { free(ptr); ptr = NULL; } while(0)


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