From: Sebastian Harl Date: Mon, 18 Aug 2008 07:30:03 +0000 (+0200) Subject: src/common.h: Make sfree() usable like a function. X-Git-Tag: collectd-4.3.4~13 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=a824bd24b2cc4c38b328f27364a26f753f5b70b0;p=collectd.git src/common.h: Make sfree() usable like a function. By putting the code into a "do { } while (0)" loop it is treated like a single statement and does not break "if () sfree()" like constructs. Signed-off-by: Sebastian Harl Signed-off-by: Florian Forster --- diff --git a/src/common.h b/src/common.h index e99aea69..9e7e4aa3 100644 --- a/src/common.h +++ b/src/common.h @@ -31,10 +31,12 @@ #endif #define sfree(ptr) \ - if((ptr) != NULL) { \ - free(ptr); \ - } \ - (ptr) = NULL + do { \ + if((ptr) != NULL) { \ + free(ptr); \ + } \ + (ptr) = NULL; \ + } while (0) #define STATIC_ARRAY_SIZE(a) (sizeof (a) / sizeof (*(a)))