mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-08-01 15:03:39 +02:00
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.
This commit is contained in:
committed by
Sebastian Wilhelmi
parent
03f9d485c1
commit
8c90d7766b
23
glist.c
23
glist.c
@@ -78,7 +78,7 @@ void
|
||||
g_list_push_allocator(GAllocator *allocator)
|
||||
{
|
||||
G_LOCK (current_allocator);
|
||||
g_list_validate_allocator ( allocator );
|
||||
g_list_validate_allocator (allocator);
|
||||
allocator->last = current_allocator;
|
||||
current_allocator = allocator;
|
||||
G_UNLOCK (current_allocator);
|
||||
@@ -151,9 +151,23 @@ g_list_free (GList *list)
|
||||
{
|
||||
if (list)
|
||||
{
|
||||
GList *last_node = list;
|
||||
|
||||
#ifdef ENABLE_GC_FRIENDLY
|
||||
while (last_node->next)
|
||||
{
|
||||
last_node->data = NULL;
|
||||
last_node->prev = NULL;
|
||||
last_node = last_node->next;
|
||||
}
|
||||
last_node->data = NULL
|
||||
last_node->prev = 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);
|
||||
}
|
||||
@@ -165,6 +179,11 @@ _g_list_free_1 (GList *list)
|
||||
if (list)
|
||||
{
|
||||
list->data = NULL;
|
||||
|
||||
#ifdef ENABLE_GC_FRIENDLY
|
||||
list->prev = NULL;
|
||||
#endif /* ENABLE_GC_FRIENDLY */
|
||||
|
||||
G_LOCK (current_allocator);
|
||||
list->next = current_allocator->free_lists;
|
||||
current_allocator->free_lists = list;
|
||||
|
Reference in New Issue
Block a user