cleanup macros.
eina_stringshare_replace() does a nice job. EINA_LIST_FREE() always exit with empty (NULL) list. SVN revision: 77667
This commit is contained in:
parent
4cd60a96e1
commit
6368cfbbc2
|
@ -39,23 +39,20 @@
|
||||||
* @def IF_RELEASE(x)
|
* @def IF_RELEASE(x)
|
||||||
* If x is set, eina_stringshare_del x and set to NULL
|
* If x is set, eina_stringshare_del x and set to NULL
|
||||||
*/
|
*/
|
||||||
#define IF_RELEASE(x) do { \
|
#define IF_RELEASE(x) eina_stringshare_replace(&(x), NULL)
|
||||||
if (x) { \
|
|
||||||
const char *__tmp; __tmp = (x); (x) = NULL; eina_stringshare_del(__tmp); \
|
|
||||||
} \
|
|
||||||
(x) = NULL; \
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @def IF_FREE_LIST(x)
|
* @def IF_FREE_LIST(x)
|
||||||
* If x is a valid pointer destroy x and set to NULL
|
* If x is a valid pointer destroy x and set to NULL
|
||||||
*/
|
*/
|
||||||
#define IF_FREE_LIST(list, free_cb) do { \
|
#define IF_FREE_LIST(list, free_cb) \
|
||||||
void *_data; \
|
do \
|
||||||
EINA_LIST_FREE(list, _data) \
|
{ \
|
||||||
free_cb(_data); \
|
void *_data; \
|
||||||
list = NULL; \
|
EINA_LIST_FREE(list, _data) \
|
||||||
} while (0)
|
free_cb(_data); \
|
||||||
|
} \
|
||||||
|
while (0)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @def IF_FREE_HASH(x)
|
* @def IF_FREE_HASH(x)
|
||||||
|
|
Loading…
Reference in New Issue