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 13:05:28 -0800
Reply-to: bugs@xxxxxxxxxxx

<URL: >

> [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.

Ok, so here's the updated patch.
Index: utility/mem.h
--- utility/mem.h       (Revision 11431)
+++ utility/mem.h       (Arbeitskopie)
@@ -29,6 +29,8 @@
                                           __LINE__, __FILE__)
 #define fc_calloc(n,esz)   fc_real_calloc((n), (esz), "calloc", \
                                           __LINE__, __FILE__)
+#define FC_FREE(ptr)       do { free(ptr); ptr = NULL; } while(0)
 #define mystrdup(str)      real_mystrdup((str), "strdup", \
                                         __LINE__, __FILE__)

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