forked from enlightenment/efl
Make IF_FREE better suited for free'ing global variables. The free cb
can now not interfere with it's owner during free. SVN revision: 30429
This commit is contained in:
parent
68159d9bdd
commit
b97be5f5c1
|
@ -803,7 +803,7 @@ efreet_icon_cache_set(Efreet_Icon_Theme *theme, const char *key, void *value)
|
|||
ecore_hash_set(theme->icon_cache, (void *)key, NO_MATCH_KEY);
|
||||
else
|
||||
{
|
||||
if (value != NO_MATCH_KEY) ((Efreet_Icon *)value)->ref_count ++;
|
||||
if (value != NO_MATCH_KEY) ((Efreet_Icon *)value)->ref_count++;
|
||||
|
||||
ecore_hash_set(theme->icon_cache, (void *)key, value);
|
||||
}
|
||||
|
@ -1021,9 +1021,9 @@ efreet_icon_theme_free(Efreet_Icon_Theme *theme)
|
|||
IF_FREE(theme->example_icon);
|
||||
|
||||
if (theme->paths.count == 1)
|
||||
IF_FREE(theme->paths.path)
|
||||
IF_FREE(theme->paths.path);
|
||||
else
|
||||
IF_FREE_LIST(theme->paths.path)
|
||||
IF_FREE_LIST(theme->paths.path);
|
||||
|
||||
IF_FREE_LIST(theme->inherits);
|
||||
IF_FREE_LIST(theme->directories);
|
||||
|
@ -1063,7 +1063,7 @@ efreet_icon_theme_path_add(Efreet_Icon_Theme *theme, const char *path)
|
|||
ecore_list_append(theme->paths.path, old);
|
||||
ecore_list_append(theme->paths.path, strdup(path));
|
||||
}
|
||||
theme->paths.count ++;
|
||||
theme->paths.count++;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -42,37 +42,57 @@
|
|||
* @def FREE(x)
|
||||
* Free x and set to NULL
|
||||
*/
|
||||
#define FREE(x) { free(x); x = NULL; }
|
||||
#define FREE(x) do { free(x); x = NULL; } while (0)
|
||||
|
||||
/**
|
||||
* @def IF_FREE(x)
|
||||
* If x is set, free x and set to NULL
|
||||
*/
|
||||
#define IF_FREE(x) { if (x) FREE(x) }
|
||||
#define IF_FREE(x) do { if (x) FREE(x); } while (0)
|
||||
|
||||
/**
|
||||
* @def IF_RELEASE(x)
|
||||
* If x is set, ecore_string_release x and set to NULL
|
||||
*/
|
||||
#define IF_RELEASE(x) { if (x) ecore_string_release(x); x = NULL; }
|
||||
#define IF_RELEASE(x) do { \
|
||||
if (x) { \
|
||||
const char *__tmp; __tmp = (x); (x) = NULL; ecore_string_release(__tmp); \
|
||||
} \
|
||||
(x) = NULL; \
|
||||
} while (0)
|
||||
|
||||
/**
|
||||
* @def IF_FREE_LIST(x)
|
||||
* If x is a valid pointer destroy x and set to NULL
|
||||
*/
|
||||
#define IF_FREE_LIST(x) { if (x) ecore_list_destroy(x); x = NULL; }
|
||||
#define IF_FREE_LIST(x) do { \
|
||||
if (x) { \
|
||||
Ecore_List *__tmp; __tmp = (x); (x) = NULL; ecore_list_destroy(__tmp); \
|
||||
} \
|
||||
(x) = NULL; \
|
||||
} while (0)
|
||||
|
||||
/**
|
||||
* @def IF_FREE_DLIST(x)
|
||||
* If x is a valid pointer destroy x and set to NULL
|
||||
*/
|
||||
#define IF_FREE_DLIST(x) { if (x) ecore_dlist_destroy(x); x = NULL; }
|
||||
#define IF_FREE_DLIST(x) do { \
|
||||
if (x) { \
|
||||
Ecore_DList *__tmp; __tmp = (x); (x) = NULL; ecore_dlist_destroy(__tmp); \
|
||||
} \
|
||||
(x) = NULL; \
|
||||
} while (0)
|
||||
|
||||
/**
|
||||
* @def IF_FREE_HASH(x)
|
||||
* If x is a valid pointer destroy x and set to NULL
|
||||
*/
|
||||
#define IF_FREE_HASH(x) { if (x) ecore_hash_destroy(x); x = NULL; }
|
||||
#define IF_FREE_HASH(x) do { \
|
||||
if (x) { \
|
||||
Ecore_Hash *__tmp; __tmp = (x); (x) = NULL; ecore_hash_destroy(__tmp); \
|
||||
} \
|
||||
(x) = NULL; \
|
||||
} while (0)
|
||||
|
||||
/**
|
||||
* @def __UNUSED__
|
||||
|
|
Loading…
Reference in New Issue