From a824bd24b2cc4c38b328f27364a26f753f5b70b0 Mon Sep 17 00:00:00 2001 From: Sebastian Harl Date: Mon, 18 Aug 2008 09:30:03 +0200 Subject: [PATCH] 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 --- src/common.h | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) 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))) -- 2.30.2