summaryrefslogtreecommitdiff
path: root/gslist.c
diff options
context:
space:
mode:
authorSebastian Wilhelmi <wilhelmi@ira.uka.de>2000-04-17 13:23:27 +0000
committerSebastian Wilhelmi <wilhelmi@src.gnome.org>2000-04-17 13:23:27 +0000
commit8c90d7766b1708a8bcb3cb96988b6b7fc92c2e59 (patch)
tree9bf74b09c3cd4b70ab5216e8085c41d3dec24f8f /gslist.c
parent03f9d485c1435c342c936a26626dda440c1911b9 (diff)
downloadglib-8c90d7766b1708a8bcb3cb96988b6b7fc92c2e59.tar.gz
Add configure test for garbage collector friendliness for GLib. If
2000-04-17 Sebastian Wilhelmi <wilhelmi@ira.uka.de> * configure.in, acconfig.h: Add configure test for garbage collector friendliness for GLib. If enabled, ENABLE_GC_FRIENDLY will be defined. * garray.c, ghash.c, glist.c, gmain.c, gmem.c, gnode.c, gqueue.c, gslist.c, gtree.c: If ENABLE_GC_FRIENDLY is defined, NULLify all memory released by the user, but cached by GLib. This lets a garbage collector have a more correct view of the actually used memory.
Diffstat (limited to 'gslist.c')
-rw-r--r--gslist.c16
1 files changed, 14 insertions, 2 deletions
diff --git a/gslist.c b/gslist.c
index 2f01673b0..bcb481f05 100644
--- a/gslist.c
+++ b/gslist.c
@@ -151,9 +151,21 @@ g_slist_free (GSList *list)
{
if (list)
{
- list->data = list->next;
+ GSList *last_node = list;
+
+#ifdef ENABLE_GC_FRIENDLY
+ while (last_node->next)
+ {
+ last_node->data = NULL;
+ last_node = last_node->next;
+ }
+ last_node->data = NULL
+#else /* !ENABLE_GC_FRIENDLY */
+ list->data = list->next;
+#endif /* ENABLE_GC_FRIENDLY */
+
G_LOCK (current_allocator);
- list->next = current_allocator->free_lists;
+ last_node->next = current_allocator->free_lists;
current_allocator->free_lists = list;
G_UNLOCK (current_allocator);
}