From c0324e9156d2166a737525d6672e219f285226b7 Mon Sep 17 00:00:00 2001 From: barbieri Date: Mon, 6 Apr 2009 21:08:27 +0000 Subject: [PATCH] cleanup list free, also fix a leak on connection->signal_handlers. git-svn-id: svn+ssh://svn.enlightenment.org/var/svn/e/trunk/e_dbus@39885 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33 --- src/lib/dbus/e_dbus.c | 12 +++--------- src/lib/dbus/e_dbus_object.c | 25 +++++++------------------ src/lib/dbus/e_dbus_private.h | 2 ++ src/lib/dbus/e_dbus_signal.c | 8 ++++++++ src/lib/hal/e_hal_manager.c | 4 +--- src/lib/hal/e_hal_util.c | 3 +-- src/lib/notification/marshal.c | 3 +-- src/lib/notification/notification.c | 3 +-- 8 files changed, 24 insertions(+), 36 deletions(-) diff --git a/src/lib/dbus/e_dbus.c b/src/lib/dbus/e_dbus.c index 32ea145..9c51e45 100644 --- a/src/lib/dbus/e_dbus.c +++ b/src/lib/dbus/e_dbus.c @@ -170,24 +170,18 @@ e_dbus_connection_free(void *data) E_DBus_Connection *cd = data; Ecore_Fd_Handler *fd_handler; Ecore_Timer *timer; - Eina_List *l; DEBUG(5, "e_dbus_connection free!\n"); - EINA_LIST_FOREACH(cd->fd_handlers, l, fd_handler) + EINA_LIST_FREE(cd->fd_handlers, fd_handler) ecore_main_fd_handler_del(fd_handler); - while (cd->fd_handlers) - cd->fd_handlers = eina_list_remove_list(cd->fd_handlers, cd->fd_handlers); - EINA_LIST_FOREACH(cd->timeouts, l, timer) + EINA_LIST_FREE(cd->timeouts, timer) ecore_timer_del(timer); - while (cd->timeouts) - cd->timeouts = eina_list_remove_list(cd->timeouts, cd->timeouts); if (cd->shared_type != -1) shared_connections[cd->shared_type] = NULL; - while (cd->signal_handlers) - cd->signal_handlers = eina_list_remove_list(cd->signal_handlers, cd->signal_handlers); + e_dbus_signal_handlers_free_all(cd); if (cd->conn_name) free(cd->conn_name); diff --git a/src/lib/dbus/e_dbus_object.c b/src/lib/dbus/e_dbus_object.c index 1b649f5..ec48925 100644 --- a/src/lib/dbus/e_dbus_object.c +++ b/src/lib/dbus/e_dbus_object.c @@ -255,12 +255,9 @@ e_dbus_object_free(E_DBus_Object *obj) e_dbus_connection_close(obj->conn); if (obj->path) free(obj->path); - while (obj->interfaces) - { - iface = eina_list_data_get(obj->interfaces); - e_dbus_interface_unref(iface); - obj->interfaces = eina_list_remove_list(obj->interfaces, obj->interfaces); - } + EINA_LIST_FREE(obj->interfaces, iface) + e_dbus_interface_unref(iface); + if (obj->introspection_data) free(obj->introspection_data); free(obj); @@ -343,18 +340,10 @@ e_dbus_interface_free(E_DBus_Interface *iface) E_DBus_Signal *s; if (iface->name) free(iface->name); - while (iface->methods) - { - m = eina_list_data_get(iface->methods); - e_dbus_object_method_free(m); - iface->methods = eina_list_remove_list(iface->methods, iface->methods); - } - while (iface->signals) - { - s = eina_list_data_get(iface->signals); - e_dbus_object_signal_free(s); - iface->signals = eina_list_remove_list(iface->signals, iface->signals); - } + EINA_LIST_FREE(iface->methods, m) + e_dbus_object_method_free(m); + EINA_LIST_FREE(iface->signals, s) + e_dbus_object_signal_free(s); free(iface); } diff --git a/src/lib/dbus/e_dbus_private.h b/src/lib/dbus/e_dbus_private.h index fe0748c..ff25559 100644 --- a/src/lib/dbus/e_dbus_private.h +++ b/src/lib/dbus/e_dbus_private.h @@ -36,6 +36,8 @@ void e_dbus_object_shutdown(void); extern int e_dbus_idler_active; void e_dbus_signal_handlers_clean(E_DBus_Connection *conn); +void e_dbus_signal_handlers_free_all(E_DBus_Connection *conn); + const char *e_dbus_basic_type_as_string(int type); diff --git a/src/lib/dbus/e_dbus_signal.c b/src/lib/dbus/e_dbus_signal.c index 36fff22..6fe239a 100644 --- a/src/lib/dbus/e_dbus_signal.c +++ b/src/lib/dbus/e_dbus_signal.c @@ -283,3 +283,11 @@ e_dbus_signal_handlers_clean(E_DBus_Connection *conn) e_dbus_signal_handler_del(conn, sh); } } + +void +e_dbus_signal_handlers_free_all(E_DBus_Connection *conn) +{ + E_DBus_Signal_Handler *sh; + EINA_LIST_FREE(conn->signal_handlers, sh) + e_dbus_signal_handler_free(sh); +} diff --git a/src/lib/hal/e_hal_manager.c b/src/lib/hal/e_hal_manager.c index 8bd3f17..891412b 100644 --- a/src/lib/hal/e_hal_manager.c +++ b/src/lib/hal/e_hal_manager.c @@ -45,9 +45,7 @@ free_string_list(void *data) E_Hal_String_List_Return *ret = data; if (!ret) return; - while (ret->strings) - ret->strings = eina_list_remove_list(ret->strings, ret->strings); - + eina_list_free(ret->strings); free(ret); } diff --git a/src/lib/hal/e_hal_util.c b/src/lib/hal/e_hal_util.c index 0661123..ad89bad 100644 --- a/src/lib/hal/e_hal_util.c +++ b/src/lib/hal/e_hal_util.c @@ -10,8 +10,7 @@ EAPI void e_hal_property_free(E_Hal_Property *prop) { if (prop->type == E_HAL_PROPERTY_TYPE_STRLIST) - while (prop->val.strlist) - prop->val.strlist = eina_list_remove_list(prop->val.strlist, prop->val.strlist); + eina_list_free(prop->val.strlist); free(prop); } diff --git a/src/lib/notification/marshal.c b/src/lib/notification/marshal.c index 6b517fb..03844a2 100644 --- a/src/lib/notification/marshal.c +++ b/src/lib/notification/marshal.c @@ -159,8 +159,7 @@ e_notify_free_get_capabilities_return(void *data) E_Notification_Return_Get_Capabilities *ret = data; if (!ret) return; - while (ret->capabilities) - ret->capabilities = eina_list_remove_list(ret->capabilities, ret->capabilities); + eina_list_free(ret->capabilities); free(ret); } diff --git a/src/lib/notification/notification.c b/src/lib/notification/notification.c index aa50b90..b8c9fb0 100644 --- a/src/lib/notification/notification.c +++ b/src/lib/notification/notification.c @@ -65,8 +65,7 @@ e_notification_free(E_Notification *n) if (n->summary) free(n->summary); if (n->body) free(n->body); - while (n->actions) - n->actions = eina_list_remove_list(n->actions, n->actions); + eina_list_free(n->actions); if (n->hints.category) free(n->hints.category); if (n->hints.desktop) free(n->hints.desktop); -- 2.7.4