diff options
author | Dmitry Podgorny <pasis.ua@gmail.com> | 2013-07-31 01:53:10 +0300 |
---|---|---|
committer | Dmitry Podgorny <pasis.ua@gmail.com> | 2013-07-31 01:58:59 +0300 |
commit | f2638e001aef47c04168784e6f45af7264bcd309 (patch) | |
tree | 915cdb8f24d5ec183210ab47b613f4d2f5c110a3 | |
parent | 5505387c37f594db0368317a2349c429c8ddedfe (diff) | |
download | profani-tty-f2638e001aef47c04168784e6f45af7264bcd309.tar.gz |
rewritten FREE_SET_NULL and GFREE_SET_NULL
NULL is valid argument for free(). Construction do {} while (0) allows using FREE_SET_NULL as one token and force to put semicolon at the end.
-rw-r--r-- | src/common.h | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/src/common.h b/src/common.h index b87f2a97..f8ed82a5 100644 --- a/src/common.h +++ b/src/common.h @@ -42,18 +42,16 @@ #define ARRAY_SIZE(x) (sizeof(x)/sizeof(x[0])) #define FREE_SET_NULL(resource) \ -{ \ - if (resource != NULL) { \ - free(resource); \ - resource = NULL; \ - } \ -} +do { \ + free(resource); \ + resource = NULL; \ +} while (0) #define GFREE_SET_NULL(resource) \ -{ \ +do { \ g_free(resource); \ resource = NULL; \ -} +} while (0) typedef enum { CONTACT_OFFLINE, |