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:
parent
5505387c37
commit
f2638e001a
14
src/common.h
14
src/common.h
@ -42,18 +42,16 @@
|
|||||||
#define ARRAY_SIZE(x) (sizeof(x)/sizeof(x[0]))
|
#define ARRAY_SIZE(x) (sizeof(x)/sizeof(x[0]))
|
||||||
|
|
||||||
#define FREE_SET_NULL(resource) \
|
#define FREE_SET_NULL(resource) \
|
||||||
{ \
|
do { \
|
||||||
if (resource != NULL) { \
|
free(resource); \
|
||||||
free(resource); \
|
resource = NULL; \
|
||||||
resource = NULL; \
|
} while (0)
|
||||||
} \
|
|
||||||
}
|
|
||||||
|
|
||||||
#define GFREE_SET_NULL(resource) \
|
#define GFREE_SET_NULL(resource) \
|
||||||
{ \
|
do { \
|
||||||
g_free(resource); \
|
g_free(resource); \
|
||||||
resource = NULL; \
|
resource = NULL; \
|
||||||
}
|
} while (0)
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
CONTACT_OFFLINE,
|
CONTACT_OFFLINE,
|
||||||
|
Loading…
Reference in New Issue
Block a user