]> git.sur5r.net Git - i3/i3/commitdiff
do not check for NULL in FREE macro 3058/head
authorDaniel Mueller <deso@posteo.net>
Thu, 23 Nov 2017 23:41:33 +0000 (15:41 -0800)
committerDaniel Mueller <deso@posteo.net>
Thu, 23 Nov 2017 23:41:33 +0000 (15:41 -0800)
free(3) is safe to invoke on a NULL pointer, in which case no action is
taken. This change adjusts the FREE macros to omit this unnecessary
check.

i3-config-wizard/main.c
i3-input/i3-input.h
i3-nagbar/i3-nagbar.h
i3bar/include/util.h
include/util.h

index dd58fd124547df7dcee0ce40785784eb1e43be4d..cbea624e330bb0f7ce56dc2a9da23aeb9850a18a 100644 (file)
 #error "SYSCONFDIR not defined"
 #endif
 
-#define FREE(pointer)          \
-    do {                       \
-        if (pointer != NULL) { \
-            free(pointer);     \
-            pointer = NULL;    \
-        }                      \
+#define FREE(pointer)   \
+    do {                \
+        free(pointer);  \
+        pointer = NULL; \
     } while (0)
 
 #include "xcb.h"
index d347506fe61e69907bc9c13fbc5672ff3fd8113c..d7aae66b5f8ffb1033f93155d5e74eed20c2146a 100644 (file)
@@ -5,12 +5,10 @@
 #include <err.h>
 
 #define die(...) errx(EXIT_FAILURE, __VA_ARGS__);
-#define FREE(pointer)          \
-    do {                       \
-        if (pointer != NULL) { \
-            free(pointer);     \
-            pointer = NULL;    \
-        }                      \
+#define FREE(pointer)   \
+    do {                \
+        free(pointer);  \
+        pointer = NULL; \
     } while (0)
 
 extern xcb_window_t root;
index c5e94cc6140fb554d3fa48f1f6b26c1c2107f1db..cb672bead868f59460f5735f94c611e444b4783f 100644 (file)
@@ -5,12 +5,10 @@
 #include <err.h>
 
 #define die(...) errx(EXIT_FAILURE, __VA_ARGS__);
-#define FREE(pointer)          \
-    do {                       \
-        if (pointer != NULL) { \
-            free(pointer);     \
-            pointer = NULL;    \
-        }                      \
+#define FREE(pointer)   \
+    do {                \
+        free(pointer);  \
+        pointer = NULL; \
     } while (0)
 
 #define xmacro(atom) xcb_atom_t A_##atom;
index 3af79ed779c9704495b7fe400f5dacd482979420..1f56361106dfc97670bc412bf5d6e2ad90fb6450 100644 (file)
 #define STARTS_WITH(string, len, needle) (((len) >= strlen((needle))) && strncasecmp((string), (needle), strlen((needle))) == 0)
 
 /* Securely free p */
-#define FREE(p)          \
-    do {                 \
-        if (p != NULL) { \
-            free(p);     \
-            p = NULL;    \
-        }                \
+#define FREE(p)   \
+    do {          \
+        free(p);  \
+        p = NULL; \
     } while (0)
 
 /* Securely free single-linked list */
index 526ab88107038ac583edd508466b23a40b4597be..3547d8d7b50df6533fc566aec682efe0e63bc1a3 100644 (file)
         break;                            \
     }
 
-#define FREE(pointer)          \
-    do {                       \
-        if (pointer != NULL) { \
-            free(pointer);     \
-            pointer = NULL;    \
-        }                      \
+#define FREE(pointer)   \
+    do {                \
+        free(pointer);  \
+        pointer = NULL; \
     } while (0)
 
 #define CALL(obj, member, ...) obj->member(obj, ##__VA_ARGS__)