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.
+
* garray.c, glib.h: Added g_(array|ptr_array|byte_array)_sized_new
functions, that reserve a certain amount of memeory for the array
at creation time to avoid reallocation. Fixes bug #6707 from
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.
+
* garray.c, glib.h: Added g_(array|ptr_array|byte_array)_sized_new
functions, that reserve a certain amount of memeory for the array
at creation time to avoid reallocation. Fixes bug #6707 from
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.
+
* garray.c, glib.h: Added g_(array|ptr_array|byte_array)_sized_new
functions, that reserve a certain amount of memeory for the array
at creation time to avoid reallocation. Fixes bug #6707 from
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.
+
* garray.c, glib.h: Added g_(array|ptr_array|byte_array)_sized_new
functions, that reserve a certain amount of memeory for the array
at creation time to avoid reallocation. Fixes bug #6707 from
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.
+
* garray.c, glib.h: Added g_(array|ptr_array|byte_array)_sized_new
functions, that reserve a certain amount of memeory for the array
at creation time to avoid reallocation. Fixes bug #6707 from
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.
+
* garray.c, glib.h: Added g_(array|ptr_array|byte_array)_sized_new
functions, that reserve a certain amount of memeory for the array
at creation time to avoid reallocation. Fixes bug #6707 from
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.
+
* garray.c, glib.h: Added g_(array|ptr_array|byte_array)_sized_new
functions, that reserve a certain amount of memeory for the array
at creation time to avoid reallocation. Fixes bug #6707 from
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.
+
* garray.c, glib.h: Added g_(array|ptr_array|byte_array)_sized_new
functions, that reserve a certain amount of memeory for the array
at creation time to avoid reallocation. Fixes bug #6707 from
#undef ENABLE_MEM_CHECK
#undef ENABLE_MEM_PROFILE
+#undef ENABLE_GC_FRIENDLY
#undef REALLOC_0_WORKS
AC_ARG_ENABLE(msg-prefix, [ --enable-msg-prefix turn on program name and PID prefixing of messages and warnings],,enable_msg_prefix=no)
AC_ARG_ENABLE(mem_check, [ --enable-mem-check turn on malloc/free sanity checking [default=no]],,enable_mem_check=no)
AC_ARG_ENABLE(mem_profile, [ --enable-mem-profile turn on malloc profiling atexit [default=no]],,enable_mem_profile=no)
+AC_ARG_ENABLE(gc_friendly, [ --enable-gc-friendly turn on garbage collector friendliness [default=no]],,enable_gc_friendly=no)
AC_ARG_ENABLE(ansi, [ --enable-ansi turn on strict ansi [default=no]],
, enable_ansi=no)
AC_ARG_ENABLE(threads, [ --enable-threads turn on basic thread support [default=yes]
AC_MSG_RESULT(no)
fi
+AC_MSG_CHECKING(whether to enable garbage collector friendliness)
+if test "x$enable_gc_friendly" = "xyes"; then
+ AC_DEFINE(ENABLE_GC_FRIENDLY, 1)
+ AC_SUBST(ENABLE_GC_FRIENDLY)
+ AC_MSG_RESULT(yes)
+else
+ AC_MSG_RESULT(no)
+fi
+
if test "x$enable_debug" = "xyes"; then
test "$cflags_set" = set || CFLAGS="$CFLAGS -g"
GLIB_DEBUG_FLAGS="-DG_ENABLE_DEBUG"
#define g_array_elt_len(array,i) ((array)->elt_size * (i))
#define g_array_elt_pos(array,i) ((array)->data + g_array_elt_len((array),(i)))
-#define g_array_elt_zero(array, pos, len) \
+#define g_array_elt_zero(array, pos, len) \
(memset (g_array_elt_pos ((array), pos), 0, g_array_elt_len ((array), len)))
-#define g_array_zero_terminate(array) G_STMT_START{ \
- if ((array)->zero_terminated) \
- g_array_elt_zero ((array), (array)->len, 1); \
+#define g_array_zero_terminate(array) G_STMT_START{ \
+ if ((array)->zero_terminated) \
+ g_array_elt_zero ((array), (array)->len, 1); \
}G_STMT_END
static gint g_nearest_pow (gint num);
guint length)
{
GRealArray *array = (GRealArray*) farray;
-
- if (array->len < length)
+ if (length > array->len)
{
g_array_maybe_expand (array, length - array->len);
if (array->clear)
g_array_elt_zero (array, array->len, length - array->len);
}
+#ifdef ENABLE_GC_FRIENDLY
+ else if (length < array->len)
+ g_array_elt_zero (array, length, array->len - length);
+#endif /* ENABLE_GC_FRIENDLY */
array->len = length;
array->len -= 1;
+#ifdef ENABLE_GC_FRIENDLY
+ g_array_elt_zero (array, array->len, 1);
+#else /* !ENABLE_GC_FRIENDLY */
g_array_zero_terminate (array);
+#endif /* ENABLE_GC_FRIENDLY */
return farray;
}
array->len -= 1;
+#ifdef ENABLE_GC_FRIENDLY
+ g_array_elt_zero (array, array->len, 1);
+#else /* !ENABLE_GC_FRIENDLY */
g_array_zero_terminate (array);
+#endif /* ENABLE_GC_FRIENDLY */
return farray;
}
if (want_alloc > array->alloc)
{
- array->alloc = g_nearest_pow (want_alloc);
- array->alloc = MAX (array->alloc, MIN_ARRAY_SIZE);
+ want_alloc = g_nearest_pow (want_alloc);
+ want_alloc = MAX (want_alloc, MIN_ARRAY_SIZE);
- array->data = g_realloc (array->data, array->alloc);
+ array->data = g_realloc (array->data, want_alloc);
+
+#ifdef ENABLE_GC_FRIENDLY
+ memset (array->data + array->alloc, 0, want_alloc - array->alloc);
+#endif /* ENABLE_GC_FRIENDLY */
+
+ array->alloc = want_alloc;
}
}
{
if ((array->len + len) > array->alloc)
{
+#ifdef ENABLE_GC_FRIENDLY
+ guint old_alloc = array->alloc;
+#endif /* ENABLE_GC_FRIENDLY */
array->alloc = g_nearest_pow (array->len + len);
array->alloc = MAX (array->alloc, MIN_ARRAY_SIZE);
array->pdata = g_realloc (array->pdata, sizeof(gpointer) * array->alloc);
+#ifdef ENABLE_GC_FRIENDLY
+ for ( ; old_alloc < array->alloc; old_alloc++)
+ array->pdata [old_alloc] = NULL;
+#endif /* ENABLE_GC_FRIENDLY */
}
}
for (i = array->len; i < length; i++)
array->pdata[i] = NULL;
}
+#ifdef ENABLE_GC_FRIENDLY
+ else if (length < array->len)
+ {
+ int i;
+ for (i = length; i < array->len; i++)
+ array->pdata[i] = NULL;
+ }
+#endif /* ENABLE_GC_FRIENDLY */
array->len = length;
}
array->len -= 1;
+#ifdef ENABLE_GC_FRIENDLY
+ array->pdata[array->len] = NULL;
+#endif /* ENABLE_GC_FRIENDLY */
+
return result;
}
array->len -= 1;
+#ifdef ENABLE_GC_FRIENDLY
+ array->pdata[array->len] = NULL;
+#endif /* ENABLE_GC_FRIENDLY */
+
return result;
}
static void
g_hash_node_destroy (GHashNode *hash_node)
{
+
+#ifdef ENABLE_GC_FRIENDLY
+ hash_node->key = NULL;
+ hash_node->value = NULL;
+#endif /* ENABLE_GC_FRIENDLY */
+
G_LOCK (g_hash_global);
hash_node->next = node_free_list;
node_free_list = hash_node;
GHashNode *node = hash_node;
while (node->next)
- node = node->next;
-
+ {
+#ifdef ENABLE_GC_FRIENDLY
+ node->key = NULL;
+ node->value = NULL;
+#endif /* ENABLE_GC_FRIENDLY */
+ node = node->next;
+ }
+
+#ifdef ENABLE_GC_FRIENDLY
+ node->key = NULL;
+ node->value = NULL;
+#endif /* ENABLE_GC_FRIENDLY */
+
G_LOCK (g_hash_global);
node->next = node_free_list;
node_free_list = hash_node;
#define g_array_elt_len(array,i) ((array)->elt_size * (i))
#define g_array_elt_pos(array,i) ((array)->data + g_array_elt_len((array),(i)))
-#define g_array_elt_zero(array, pos, len) \
+#define g_array_elt_zero(array, pos, len) \
(memset (g_array_elt_pos ((array), pos), 0, g_array_elt_len ((array), len)))
-#define g_array_zero_terminate(array) G_STMT_START{ \
- if ((array)->zero_terminated) \
- g_array_elt_zero ((array), (array)->len, 1); \
+#define g_array_zero_terminate(array) G_STMT_START{ \
+ if ((array)->zero_terminated) \
+ g_array_elt_zero ((array), (array)->len, 1); \
}G_STMT_END
static gint g_nearest_pow (gint num);
guint length)
{
GRealArray *array = (GRealArray*) farray;
-
- if (array->len < length)
+ if (length > array->len)
{
g_array_maybe_expand (array, length - array->len);
if (array->clear)
g_array_elt_zero (array, array->len, length - array->len);
}
+#ifdef ENABLE_GC_FRIENDLY
+ else if (length < array->len)
+ g_array_elt_zero (array, length, array->len - length);
+#endif /* ENABLE_GC_FRIENDLY */
array->len = length;
array->len -= 1;
+#ifdef ENABLE_GC_FRIENDLY
+ g_array_elt_zero (array, array->len, 1);
+#else /* !ENABLE_GC_FRIENDLY */
g_array_zero_terminate (array);
+#endif /* ENABLE_GC_FRIENDLY */
return farray;
}
array->len -= 1;
+#ifdef ENABLE_GC_FRIENDLY
+ g_array_elt_zero (array, array->len, 1);
+#else /* !ENABLE_GC_FRIENDLY */
g_array_zero_terminate (array);
+#endif /* ENABLE_GC_FRIENDLY */
return farray;
}
if (want_alloc > array->alloc)
{
- array->alloc = g_nearest_pow (want_alloc);
- array->alloc = MAX (array->alloc, MIN_ARRAY_SIZE);
+ want_alloc = g_nearest_pow (want_alloc);
+ want_alloc = MAX (want_alloc, MIN_ARRAY_SIZE);
- array->data = g_realloc (array->data, array->alloc);
+ array->data = g_realloc (array->data, want_alloc);
+
+#ifdef ENABLE_GC_FRIENDLY
+ memset (array->data + array->alloc, 0, want_alloc - array->alloc);
+#endif /* ENABLE_GC_FRIENDLY */
+
+ array->alloc = want_alloc;
}
}
{
if ((array->len + len) > array->alloc)
{
+#ifdef ENABLE_GC_FRIENDLY
+ guint old_alloc = array->alloc;
+#endif /* ENABLE_GC_FRIENDLY */
array->alloc = g_nearest_pow (array->len + len);
array->alloc = MAX (array->alloc, MIN_ARRAY_SIZE);
array->pdata = g_realloc (array->pdata, sizeof(gpointer) * array->alloc);
+#ifdef ENABLE_GC_FRIENDLY
+ for ( ; old_alloc < array->alloc; old_alloc++)
+ array->pdata [old_alloc] = NULL;
+#endif /* ENABLE_GC_FRIENDLY */
}
}
for (i = array->len; i < length; i++)
array->pdata[i] = NULL;
}
+#ifdef ENABLE_GC_FRIENDLY
+ else if (length < array->len)
+ {
+ int i;
+ for (i = length; i < array->len; i++)
+ array->pdata[i] = NULL;
+ }
+#endif /* ENABLE_GC_FRIENDLY */
array->len = length;
}
array->len -= 1;
+#ifdef ENABLE_GC_FRIENDLY
+ array->pdata[array->len] = NULL;
+#endif /* ENABLE_GC_FRIENDLY */
+
return result;
}
array->len -= 1;
+#ifdef ENABLE_GC_FRIENDLY
+ array->pdata[array->len] = NULL;
+#endif /* ENABLE_GC_FRIENDLY */
+
return result;
}
static void
g_hash_node_destroy (GHashNode *hash_node)
{
+
+#ifdef ENABLE_GC_FRIENDLY
+ hash_node->key = NULL;
+ hash_node->value = NULL;
+#endif /* ENABLE_GC_FRIENDLY */
+
G_LOCK (g_hash_global);
hash_node->next = node_free_list;
node_free_list = hash_node;
GHashNode *node = hash_node;
while (node->next)
- node = node->next;
-
+ {
+#ifdef ENABLE_GC_FRIENDLY
+ node->key = NULL;
+ node->value = NULL;
+#endif /* ENABLE_GC_FRIENDLY */
+ node = node->next;
+ }
+
+#ifdef ENABLE_GC_FRIENDLY
+ node->key = NULL;
+ node->value = NULL;
+#endif /* ENABLE_GC_FRIENDLY */
+
G_LOCK (g_hash_global);
node->next = node_free_list;
node_free_list = hash_node;
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);
{
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);
}
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;
else
poll_records = pollrec->next;
+#ifdef ENABLE_GC_FRIENDLY
+ pollrec->fd = NULL;
+#endif /* ENABLE_GC_FRIENDLY */
+
pollrec->next = poll_free_list;
poll_free_list = pollrec;
}
else
{
+#ifdef ENABLE_GC_FRIENDLY
+ rmem_chunk->mem_area = (GMemArea*) g_malloc0 (sizeof (GMemArea) -
+ MEM_AREA_SIZE +
+ rmem_chunk->area_size);
+#else /* !ENABLE_GC_FRIENDLY */
rmem_chunk->mem_area = (GMemArea*) g_malloc (sizeof (GMemArea) -
MEM_AREA_SIZE +
rmem_chunk->area_size);
+#endif /* ENABLE_GC_FRIENDLY */
rmem_chunk->num_mem_areas += 1;
rmem_chunk->mem_area->next = rmem_chunk->mem_areas;
rmem_chunk = (GRealMemChunk*) mem_chunk;
+#ifdef ENABLE_GC_FRIENDLY
+ memset (mem, 0, rmem_chunk->atom_size);
+#endif /* ENABLE_GC_FRIENDLY */
+
/* Don't do anything if this is an ALLOC_ONLY chunk
*/
if (rmem_chunk->type == G_ALLOC_AND_FREE)
g_node_push_allocator (GAllocator *allocator)
{
G_LOCK (current_allocator);
- g_node_validate_allocator ( allocator );
+ g_node_validate_allocator (allocator);
allocator->last = current_allocator;
current_allocator = allocator;
G_UNLOCK (current_allocator);
{
if (parent->children)
g_nodes_free (parent->children);
+
+#ifdef ENABLE_GC_FRIENDLY
+ parent->data = NULL;
+ parent->prev = NULL;
+ parent->parent = NULL;
+ parent->children = NULL;
+#endif /* ENABLE_GC_FRIENDLY */
+
if (parent->next)
parent = parent->next;
else
g_list_free (queue->head);
+#ifdef ENABLE_GC_FRIENDLY
+ queue->head = NULL;
+ queue->tail = NULL;
+#endif /* ENABLE_GC_FRIENDLY */
+
G_LOCK (queue_memchunk);
g_trash_stack_push (&free_queue_nodes, queue);
G_UNLOCK (queue_memchunk);
{
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);
}
{
g_tree_node_destroy (node->right);
g_tree_node_destroy (node->left);
+
+#ifdef ENABLE_GC_FRIENDLY
+ node->left = NULL;
+ node->key = NULL;
+ node->value = NULL;
+#endif /* ENABLE_GC_FRIENDLY */
+
G_LOCK (g_tree_global);
node->right = node_free_list;
node_free_list = node;
node = g_tree_node_restore_right_balance (new_root, old_balance);
}
+#ifdef ENABLE_GC_FRIENDLY
+ garbage->left = NULL;
+ garbage->key = NULL;
+ garbage->value = NULL;
+#endif /* ENABLE_GC_FRIENDLY */
+
G_LOCK (g_tree_global);
garbage->right = node_free_list;
node_free_list = garbage;
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);
{
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);
}
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;
else
poll_records = pollrec->next;
+#ifdef ENABLE_GC_FRIENDLY
+ pollrec->fd = NULL;
+#endif /* ENABLE_GC_FRIENDLY */
+
pollrec->next = poll_free_list;
poll_free_list = pollrec;
}
else
{
+#ifdef ENABLE_GC_FRIENDLY
+ rmem_chunk->mem_area = (GMemArea*) g_malloc0 (sizeof (GMemArea) -
+ MEM_AREA_SIZE +
+ rmem_chunk->area_size);
+#else /* !ENABLE_GC_FRIENDLY */
rmem_chunk->mem_area = (GMemArea*) g_malloc (sizeof (GMemArea) -
MEM_AREA_SIZE +
rmem_chunk->area_size);
+#endif /* ENABLE_GC_FRIENDLY */
rmem_chunk->num_mem_areas += 1;
rmem_chunk->mem_area->next = rmem_chunk->mem_areas;
rmem_chunk = (GRealMemChunk*) mem_chunk;
+#ifdef ENABLE_GC_FRIENDLY
+ memset (mem, 0, rmem_chunk->atom_size);
+#endif /* ENABLE_GC_FRIENDLY */
+
/* Don't do anything if this is an ALLOC_ONLY chunk
*/
if (rmem_chunk->type == G_ALLOC_AND_FREE)
g_node_push_allocator (GAllocator *allocator)
{
G_LOCK (current_allocator);
- g_node_validate_allocator ( allocator );
+ g_node_validate_allocator (allocator);
allocator->last = current_allocator;
current_allocator = allocator;
G_UNLOCK (current_allocator);
{
if (parent->children)
g_nodes_free (parent->children);
+
+#ifdef ENABLE_GC_FRIENDLY
+ parent->data = NULL;
+ parent->prev = NULL;
+ parent->parent = NULL;
+ parent->children = NULL;
+#endif /* ENABLE_GC_FRIENDLY */
+
if (parent->next)
parent = parent->next;
else
g_list_free (queue->head);
+#ifdef ENABLE_GC_FRIENDLY
+ queue->head = NULL;
+ queue->tail = NULL;
+#endif /* ENABLE_GC_FRIENDLY */
+
G_LOCK (queue_memchunk);
g_trash_stack_push (&free_queue_nodes, queue);
G_UNLOCK (queue_memchunk);
{
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);
}
{
g_tree_node_destroy (node->right);
g_tree_node_destroy (node->left);
+
+#ifdef ENABLE_GC_FRIENDLY
+ node->left = NULL;
+ node->key = NULL;
+ node->value = NULL;
+#endif /* ENABLE_GC_FRIENDLY */
+
G_LOCK (g_tree_global);
node->right = node_free_list;
node_free_list = node;
node = g_tree_node_restore_right_balance (new_root, old_balance);
}
+#ifdef ENABLE_GC_FRIENDLY
+ garbage->left = NULL;
+ garbage->key = NULL;
+ garbage->value = NULL;
+#endif /* ENABLE_GC_FRIENDLY */
+
G_LOCK (g_tree_global);
garbage->right = node_free_list;
node_free_list = garbage;