[glib] Revert "Optimize g_[s]list_free_full a bit"
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib] Revert "Optimize g_[s]list_free_full a bit"
- Date: Thu, 28 Jul 2011 03:28:56 +0000 (UTC)
commit d15f8682c006c8f5c3d4a93db0f211f687fb656e
Author: Matthias Clasen <mclasen redhat com>
Date: Wed Jul 27 23:27:24 2011 -0400
Revert "Optimize g_[s]list_free_full a bit"
This reverts commit 98b667d052b1274f80b8898a32d0753e9e2e5c1a.
The commit was not actually an optimization, since g_list_free is
pretty smart.
glib/glist.c | 11 +++--------
glib/gslist.c | 17 ++++++-----------
2 files changed, 9 insertions(+), 19 deletions(-)
---
diff --git a/glib/glist.c b/glib/glist.c
index 7f5df44..1e3dd86 100644
--- a/glib/glist.c
+++ b/glib/glist.c
@@ -212,15 +212,10 @@ g_list_free_1 (GList *list)
*/
void
g_list_free_full (GList *list,
- GDestroyNotify free_func)
+ GDestroyNotify free_func)
{
- while (list)
- {
- GList *next = list->next;
- (*free_func) (list->data);
- _g_list_free1 (list);
- list = next;
- }
+ g_list_foreach (list, (GFunc) free_func, NULL);
+ g_list_free (list);
}
/**
diff --git a/glib/gslist.c b/glib/gslist.c
index 96ba579..1de9c57 100644
--- a/glib/gslist.c
+++ b/glib/gslist.c
@@ -197,22 +197,17 @@ g_slist_free_1 (GSList *list)
* @list: a pointer to a #GSList
* @free_func: the function to be called to free each element's data
*
- * Convenience method, which frees all the memory used by a #GSList,
- * and calls the specified destroy function on every element's data.
+ * Convenience method, which frees all the memory used by a #GSList, and
+ * calls the specified destroy function on every element's data.
*
* Since: 2.28
- */
+ **/
void
g_slist_free_full (GSList *list,
- GDestroyNotify free_func)
+ GDestroyNotify free_func)
{
- while (list)
- {
- GSList *next = list->next;
- (*free_func) (list->data);
- _g_slist_free1 (list);
- list = next;
- }
+ g_slist_foreach (list, (GFunc) free_func, NULL);
+ g_slist_free (list);
}
/**
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]