From 06a152f47e154faa8e4b0e007569cc2f29585bfd Mon Sep 17 00:00:00 2001 From: Gustavo Sverzut Barbieri Date: Wed, 25 Feb 2009 20:18:38 +0000 Subject: [PATCH] use EINA_LIST_FREE() This macro helps releasing a list of elements in efficient and safe way. SVN revision: 39217 --- src/lib/elm_genlist.c | 23 ++++++++++------------- src/lib/elm_hover.c | 6 +++--- src/lib/elm_layout.c | 5 ++--- src/lib/elm_list.c | 5 ++--- src/lib/elm_main.c | 10 ++++------ src/lib/elm_theme.c | 11 ++++------- src/lib/elm_toolbar.c | 5 ++--- src/lib/elm_widget.c | 4 +--- 8 files changed, 28 insertions(+), 41 deletions(-) diff --git a/src/lib/elm_genlist.c b/src/lib/elm_genlist.c index c92805d..6f5da6a 100644 --- a/src/lib/elm_genlist.c +++ b/src/lib/elm_genlist.c @@ -205,11 +205,9 @@ _stringlist_get(const char *str) static void _stringlist_free(Eina_List *list) { - while (list) - { - eina_stringshare_del(list->data); - list = eina_list_remove_list(list, list); - } + const char *s; + EINA_LIST_FREE(list, s) + eina_stringshare_del(list->data); } static void @@ -406,11 +404,11 @@ _item_unrealize(Elm_Genlist_Item *it) _stringlist_free(it->icons); it->icons = NULL; _stringlist_free(it->states); - while (it->icon_objs) - { - evas_object_del(it->icon_objs->data); - it->icon_objs = eina_list_remove_list(it->icon_objs, it->icon_objs); - } + + Evas_Object *icon; + EINA_LIST_FREE(it->icon_objs, icon) + evas_object_del(icon); + it->states = NULL; it->realized = 0; } @@ -799,12 +797,11 @@ _item_block_del(Elm_Genlist_Item *it) Item_Block *itbn = (Item_Block *)(il->next); if ((itbp) && ((itbp->count + itb->count) < 48)) { - while (itb->items) + Elm_Genlist_Item *it2; + EINA_LIST_FREE(itb->items, it2) { - Elm_Genlist_Item *it2 = itb->items->data; it2->block = itbp; itbp->items = eina_list_append(itbp->items, it2); - itb->items = eina_list_remove_list(itb->items, itb->items); itbp->count++; itbp->changed = 1; } diff --git a/src/lib/elm_hover.c b/src/lib/elm_hover.c index b73dd9f..f911d3c 100644 --- a/src/lib/elm_hover.c +++ b/src/lib/elm_hover.c @@ -45,10 +45,10 @@ _del_pre_hook(Evas_Object *obj) evas_object_event_callback_del(wd->hov, EVAS_CALLBACK_RESIZE, _hov_resize); evas_object_event_callback_del(wd->hov, EVAS_CALLBACK_SHOW, _hov_show); evas_object_event_callback_del(wd->hov, EVAS_CALLBACK_HIDE, _hov_hide); - while (wd->subs) + + Subinfo *si; + EINA_LIST_FREE(wd->subs, si) { - Subinfo *si = wd->subs->data; - wd->subs = eina_list_remove_list(wd->subs, wd->subs); evas_stringshare_del(si->swallow); free(si); } diff --git a/src/lib/elm_layout.c b/src/lib/elm_layout.c index a5cdbec..519df36 100644 --- a/src/lib/elm_layout.c +++ b/src/lib/elm_layout.c @@ -26,10 +26,9 @@ static void _del_hook(Evas_Object *obj) { Widget_Data *wd = elm_widget_data_get(obj); - while (wd->subs) + Subinfo *si; + EINA_LIST_FREE(wd->subs, si) { - Subinfo *si = wd->subs->data; - wd->subs = eina_list_remove_list(wd->subs, wd->subs); evas_stringshare_del(si->swallow); free(si); } diff --git a/src/lib/elm_list.c b/src/lib/elm_list.c index 1c4c6a6..fcc1dcf 100644 --- a/src/lib/elm_list.c +++ b/src/lib/elm_list.c @@ -42,10 +42,9 @@ static void _del_hook(Evas_Object *obj) { Widget_Data *wd = elm_widget_data_get(obj); - while (wd->items) + Elm_List_Item *it; + EINA_LIST_FREE(wd->items, it) { - Elm_List_Item *it = wd->items->data; - wd->items = eina_list_remove_list(wd->items, wd->items); eina_stringshare_del(it->label); if (!it->fixed) { diff --git a/src/lib/elm_main.c b/src/lib/elm_main.c index d688275..c17da2d 100644 --- a/src/lib/elm_main.c +++ b/src/lib/elm_main.c @@ -369,12 +369,10 @@ elm_quicklaunch_shutdown(void) eina_stringshare_del(_elm_data_dir); _elm_data_dir = NULL; - while (_elm_config->font_dirs) - { - eina_stringshare_del(_elm_config->font_dirs->data); - _elm_config->font_dirs = eina_list_remove_list(_elm_config->font_dirs, _elm_config->font_dirs); - } - + const char *fontdir; + EINA_LIST_FREE(_elm_config->font_dirs, fontdir) + eina_stringshare_del(fontdir); + ecore_event_handler_del(_elm_exit_handler); _elm_exit_handler = NULL; diff --git a/src/lib/elm_theme.c b/src/lib/elm_theme.c index 3e04eea..4300bb1 100644 --- a/src/lib/elm_theme.c +++ b/src/lib/elm_theme.c @@ -190,13 +190,10 @@ _elm_theme_parse(const char *theme) cache = NULL; } cache = eina_hash_string_superfast_new(NULL); - - while (themes) - { - eina_stringshare_del(themes->data); - themes = eina_list_remove_list(themes, themes); - } - + + EINA_LIST_FREE(themes, p) + eina_stringshare_del(p); + themes = names; return 1; } diff --git a/src/lib/elm_toolbar.c b/src/lib/elm_toolbar.c index ae5b928..8dd5693 100644 --- a/src/lib/elm_toolbar.c +++ b/src/lib/elm_toolbar.c @@ -66,10 +66,9 @@ static void _del_hook(Evas_Object *obj) { Widget_Data *wd = elm_widget_data_get(obj); - while (wd->items) + Elm_Toolbar_Item *it; + EINA_LIST_FREE(wd->items, it) { - Elm_Toolbar_Item *it = wd->items->data; - wd->items = eina_list_remove_list(wd->items, wd->items); eina_stringshare_del(it->label); if (it->icon) evas_object_del(it->icon); evas_object_del(it->base); diff --git a/src/lib/elm_widget.c b/src/lib/elm_widget.c index 4258d6e..7d0cbd2 100644 --- a/src/lib/elm_widget.c +++ b/src/lib/elm_widget.c @@ -788,10 +788,8 @@ _smart_del(Evas_Object *obj) evas_object_smart_callback_call(sd->obj, "sub-object-del", sobj); evas_object_del(sobj); } - while (sd->subobjs) + EINA_LIST_FREE(sd->subobjs, sobj) { - sobj = sd->subobjs->data; - sd->subobjs = eina_list_remove_list(sd->subobjs, sd->subobjs); evas_object_event_callback_del(sobj, EVAS_CALLBACK_DEL, _sub_obj_del); evas_object_smart_callback_call(sd->obj, "sub-object-del", sobj); evas_object_del(sobj); -- 2.7.4