[Freeciv-Dev] (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 >
> [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__)
- [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 <=
- [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/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
|
|