Hi tech,

Forwarding this in case it is considered useful.
Trying to clean up xfree() macro in awk.
Remove check for NULL before calling free().
As a side effect, we might set something to NULL which is already NULL (but I 
suppose that's ok).

- Michael


Index: awk.h
===================================================================
RCS file: /cvs/src/usr.bin/awk/awk.h,v
retrieving revision 1.13
diff -u -p -u -r1.13 awk.h
--- awk.h       6 Oct 2008 20:38:33 -0000       1.13
+++ awk.h       25 Feb 2015 05:29:37 -0000
@@ -31,7 +31,11 @@ typedef double       Awkfloat;
 
 typedef        unsigned char uschar;
 
-#define        xfree(a)        { if ((a) != NULL) { free((void *) (a)); (a) = 
NULL; } }
+#define        xfree(a)   \
+do {                      \
+       free((void *)(a)); \
+       (a) = NULL;        \
+} while (0)
 
 #define        NN(p)   ((p) ? (p) : "(null)")  /* guaranteed non-null for 
dprintf 
 */

Reply via email to