1
0
mirror of https://github.com/profanity-im/profanity.git synced 2024-12-04 14:46:46 -05:00

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.
This commit is contained in:
Dmitry Podgorny 2013-07-31 01:53:10 +03:00
parent 5505387c37
commit f2638e001a

View File

@ -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,