mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-02-08 03:45:49 +01:00
Patch from Morten Welinder to make ghash.c properly obey
Thu Nov 21 16:19:21 2002 Owen Taylor <otaylor@redhat.com> * glib/ghash.c: Patch from Morten Welinder to make ghash.c properly obey DISABLE_MEM_POOLS. (#96600)
This commit is contained in:
parent
eaf8e13856
commit
a436817718
@ -1,3 +1,8 @@
|
|||||||
|
Thu Nov 21 16:19:21 2002 Owen Taylor <otaylor@redhat.com>
|
||||||
|
|
||||||
|
* glib/ghash.c: Patch from Morten Welinder to
|
||||||
|
make ghash.c properly obey DISABLE_MEM_POOLS. (#96600)
|
||||||
|
|
||||||
Thu Nov 21 14:09:44 2002 Owen Taylor <otaylor@redhat.com>
|
Thu Nov 21 14:09:44 2002 Owen Taylor <otaylor@redhat.com>
|
||||||
|
|
||||||
* glib/gmacros.h: Add G_GNUC_DEPRECATED. (Tom Tromey,
|
* glib/gmacros.h: Add G_GNUC_DEPRECATED. (Tom Tromey,
|
||||||
|
@ -1,3 +1,8 @@
|
|||||||
|
Thu Nov 21 16:19:21 2002 Owen Taylor <otaylor@redhat.com>
|
||||||
|
|
||||||
|
* glib/ghash.c: Patch from Morten Welinder to
|
||||||
|
make ghash.c properly obey DISABLE_MEM_POOLS. (#96600)
|
||||||
|
|
||||||
Thu Nov 21 14:09:44 2002 Owen Taylor <otaylor@redhat.com>
|
Thu Nov 21 14:09:44 2002 Owen Taylor <otaylor@redhat.com>
|
||||||
|
|
||||||
* glib/gmacros.h: Add G_GNUC_DEPRECATED. (Tom Tromey,
|
* glib/gmacros.h: Add G_GNUC_DEPRECATED. (Tom Tromey,
|
||||||
|
@ -1,3 +1,8 @@
|
|||||||
|
Thu Nov 21 16:19:21 2002 Owen Taylor <otaylor@redhat.com>
|
||||||
|
|
||||||
|
* glib/ghash.c: Patch from Morten Welinder to
|
||||||
|
make ghash.c properly obey DISABLE_MEM_POOLS. (#96600)
|
||||||
|
|
||||||
Thu Nov 21 14:09:44 2002 Owen Taylor <otaylor@redhat.com>
|
Thu Nov 21 14:09:44 2002 Owen Taylor <otaylor@redhat.com>
|
||||||
|
|
||||||
* glib/gmacros.h: Add G_GNUC_DEPRECATED. (Tom Tromey,
|
* glib/gmacros.h: Add G_GNUC_DEPRECATED. (Tom Tromey,
|
||||||
|
@ -1,3 +1,8 @@
|
|||||||
|
Thu Nov 21 16:19:21 2002 Owen Taylor <otaylor@redhat.com>
|
||||||
|
|
||||||
|
* glib/ghash.c: Patch from Morten Welinder to
|
||||||
|
make ghash.c properly obey DISABLE_MEM_POOLS. (#96600)
|
||||||
|
|
||||||
Thu Nov 21 14:09:44 2002 Owen Taylor <otaylor@redhat.com>
|
Thu Nov 21 14:09:44 2002 Owen Taylor <otaylor@redhat.com>
|
||||||
|
|
||||||
* glib/gmacros.h: Add G_GNUC_DEPRECATED. (Tom Tromey,
|
* glib/gmacros.h: Add G_GNUC_DEPRECATED. (Tom Tromey,
|
||||||
|
@ -1,3 +1,8 @@
|
|||||||
|
Thu Nov 21 16:19:21 2002 Owen Taylor <otaylor@redhat.com>
|
||||||
|
|
||||||
|
* glib/ghash.c: Patch from Morten Welinder to
|
||||||
|
make ghash.c properly obey DISABLE_MEM_POOLS. (#96600)
|
||||||
|
|
||||||
Thu Nov 21 14:09:44 2002 Owen Taylor <otaylor@redhat.com>
|
Thu Nov 21 14:09:44 2002 Owen Taylor <otaylor@redhat.com>
|
||||||
|
|
||||||
* glib/gmacros.h: Add G_GNUC_DEPRECATED. (Tom Tromey,
|
* glib/gmacros.h: Add G_GNUC_DEPRECATED. (Tom Tromey,
|
||||||
|
@ -1,3 +1,8 @@
|
|||||||
|
Thu Nov 21 16:19:21 2002 Owen Taylor <otaylor@redhat.com>
|
||||||
|
|
||||||
|
* glib/ghash.c: Patch from Morten Welinder to
|
||||||
|
make ghash.c properly obey DISABLE_MEM_POOLS. (#96600)
|
||||||
|
|
||||||
Thu Nov 21 14:09:44 2002 Owen Taylor <otaylor@redhat.com>
|
Thu Nov 21 14:09:44 2002 Owen Taylor <otaylor@redhat.com>
|
||||||
|
|
||||||
* glib/gmacros.h: Add G_GNUC_DEPRECATED. (Tom Tromey,
|
* glib/gmacros.h: Add G_GNUC_DEPRECATED. (Tom Tromey,
|
||||||
|
@ -1,3 +1,8 @@
|
|||||||
|
Thu Nov 21 16:19:21 2002 Owen Taylor <otaylor@redhat.com>
|
||||||
|
|
||||||
|
* glib/ghash.c: Patch from Morten Welinder to
|
||||||
|
make ghash.c properly obey DISABLE_MEM_POOLS. (#96600)
|
||||||
|
|
||||||
Thu Nov 21 14:09:44 2002 Owen Taylor <otaylor@redhat.com>
|
Thu Nov 21 14:09:44 2002 Owen Taylor <otaylor@redhat.com>
|
||||||
|
|
||||||
* glib/gmacros.h: Add G_GNUC_DEPRECATED. (Tom Tromey,
|
* glib/gmacros.h: Add G_GNUC_DEPRECATED. (Tom Tromey,
|
||||||
|
25
glib/ghash.c
25
glib/ghash.c
@ -85,10 +85,12 @@ static guint g_hash_table_foreach_remove_or_steal (GHashTable *hash_table,
|
|||||||
gboolean notify);
|
gboolean notify);
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef DISABLE_MEM_POOLS
|
||||||
G_LOCK_DEFINE_STATIC (g_hash_global);
|
G_LOCK_DEFINE_STATIC (g_hash_global);
|
||||||
|
|
||||||
static GMemChunk *node_mem_chunk = NULL;
|
static GMemChunk *node_mem_chunk = NULL;
|
||||||
static GHashNode *node_free_list = NULL;
|
static GHashNode *node_free_list = NULL;
|
||||||
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* g_hash_table_new:
|
* g_hash_table_new:
|
||||||
@ -612,6 +614,9 @@ g_hash_node_new (gpointer key,
|
|||||||
{
|
{
|
||||||
GHashNode *hash_node;
|
GHashNode *hash_node;
|
||||||
|
|
||||||
|
#ifdef DISABLE_MEM_POOLS
|
||||||
|
hash_node = g_new (GHashNode, 1);
|
||||||
|
#else
|
||||||
G_LOCK (g_hash_global);
|
G_LOCK (g_hash_global);
|
||||||
if (node_free_list)
|
if (node_free_list)
|
||||||
{
|
{
|
||||||
@ -628,6 +633,7 @@ g_hash_node_new (gpointer key,
|
|||||||
hash_node = g_chunk_new (GHashNode, node_mem_chunk);
|
hash_node = g_chunk_new (GHashNode, node_mem_chunk);
|
||||||
}
|
}
|
||||||
G_UNLOCK (g_hash_global);
|
G_UNLOCK (g_hash_global);
|
||||||
|
#endif
|
||||||
|
|
||||||
hash_node->key = key;
|
hash_node->key = key;
|
||||||
hash_node->value = value;
|
hash_node->value = value;
|
||||||
@ -651,10 +657,14 @@ g_hash_node_destroy (GHashNode *hash_node,
|
|||||||
hash_node->value = NULL;
|
hash_node->value = NULL;
|
||||||
#endif /* ENABLE_GC_FRIENDLY */
|
#endif /* ENABLE_GC_FRIENDLY */
|
||||||
|
|
||||||
|
#ifdef DISABLE_MEM_POOLS
|
||||||
|
g_free (hash_node);
|
||||||
|
#else
|
||||||
G_LOCK (g_hash_global);
|
G_LOCK (g_hash_global);
|
||||||
hash_node->next = node_free_list;
|
hash_node->next = node_free_list;
|
||||||
node_free_list = hash_node;
|
node_free_list = hash_node;
|
||||||
G_UNLOCK (g_hash_global);
|
G_UNLOCK (g_hash_global);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -662,6 +672,20 @@ g_hash_nodes_destroy (GHashNode *hash_node,
|
|||||||
GFreeFunc key_destroy_func,
|
GFreeFunc key_destroy_func,
|
||||||
GFreeFunc value_destroy_func)
|
GFreeFunc value_destroy_func)
|
||||||
{
|
{
|
||||||
|
#ifdef DISABLE_MEM_POOLS
|
||||||
|
while (hash_node)
|
||||||
|
{
|
||||||
|
GHashNode *next = hash_node->next;
|
||||||
|
|
||||||
|
if (key_destroy_func)
|
||||||
|
key_destroy_func (hash_node->key);
|
||||||
|
if (value_destroy_func)
|
||||||
|
value_destroy_func (hash_node->value);
|
||||||
|
|
||||||
|
g_free (hash_node);
|
||||||
|
hash_node = next;
|
||||||
|
}
|
||||||
|
#else
|
||||||
if (hash_node)
|
if (hash_node)
|
||||||
{
|
{
|
||||||
GHashNode *node = hash_node;
|
GHashNode *node = hash_node;
|
||||||
@ -696,4 +720,5 @@ g_hash_nodes_destroy (GHashNode *hash_node,
|
|||||||
node_free_list = hash_node;
|
node_free_list = hash_node;
|
||||||
G_UNLOCK (g_hash_global);
|
G_UNLOCK (g_hash_global);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user