Index: glib/glist.c
===================================================================
RCS file: /cvs/gnome/glib/glib/glist.c,v
retrieving revision 1.30
diff -u -r1.30 glist.c
--- glib/glist.c	14 Mar 2005 04:26:57 -0000	1.30
+++ glib/glist.c	26 Sep 2005 03:58:59 -0000
@@ -33,183 +33,13 @@
 #include "glib.h"
 #include "galias.h"
 
-
-#ifndef DISABLE_MEM_POOLS
-struct _GAllocator /* from gmem.c */
-{
-  gchar         *name;
-  guint16        n_preallocs;
-  guint          is_unused : 1;
-  guint          type : 4;
-  GAllocator    *last;
-  GMemChunk     *mem_chunk;
-  GList		*free_lists; /* implementation specific */
-};
-
-static GAllocator	*current_allocator = NULL;
-G_LOCK_DEFINE_STATIC (current_allocator);
-
-/* HOLDS: current_allocator_lock */
-static void
-g_list_validate_allocator (GAllocator *allocator)
-{
-  g_return_if_fail (allocator != NULL);
-  g_return_if_fail (allocator->is_unused == TRUE);
-
-  if (allocator->type != G_ALLOCATOR_LIST)
-    {
-      allocator->type = G_ALLOCATOR_LIST;
-      if (allocator->mem_chunk)
-	{
-	  g_mem_chunk_destroy (allocator->mem_chunk);
-	  allocator->mem_chunk = NULL;
-	}
-    }
-
-  if (!allocator->mem_chunk)
-    {
-      allocator->mem_chunk = g_mem_chunk_new (allocator->name,
-					      sizeof (GList),
-					      sizeof (GList) * allocator->n_preallocs,
-					      G_ALLOC_ONLY);
-      allocator->free_lists = NULL;
-    }
-
-  allocator->is_unused = FALSE;
-}
-
-void
-g_list_push_allocator(GAllocator *allocator)
-{
-  G_LOCK (current_allocator);
-  g_list_validate_allocator (allocator);
-  allocator->last = current_allocator;
-  current_allocator = allocator;
-  G_UNLOCK (current_allocator);
-}
-
-void
-g_list_pop_allocator (void)
-{
-  G_LOCK (current_allocator);
-  if (current_allocator)
-    {
-      GAllocator *allocator;
-
-      allocator = current_allocator;
-      current_allocator = allocator->last;
-      allocator->last = NULL;
-      allocator->is_unused = TRUE;
-    }
-  G_UNLOCK (current_allocator);
-}
-
-static inline GList*
-_g_list_alloc (void)
-{
-  GList *list;
-
-  G_LOCK (current_allocator);
-  if (!current_allocator)
-    {
-      GAllocator *allocator = g_allocator_new ("GLib default GList allocator",
-					       128);
-      g_list_validate_allocator (allocator);
-      allocator->last = NULL;
-      current_allocator = allocator;
-    }
-  if (!current_allocator->free_lists)
-    {
-      list = g_chunk_new (GList, current_allocator->mem_chunk);
-      list->data = NULL;
-    }
-  else
-    {
-      if (current_allocator->free_lists->data)
-	{
-	  list = current_allocator->free_lists->data;
-	  current_allocator->free_lists->data = list->next;
-	  list->data = NULL;
-	}
-      else
-	{
-	  list = current_allocator->free_lists;
-	  current_allocator->free_lists = list->next;
-	}
-    }
-  G_UNLOCK (current_allocator);
-  list->next = NULL;
-  list->prev = NULL;
-  
-  return list;
-}
-
-GList*
-g_list_alloc (void)
-{
-  return _g_list_alloc ();
-}
-
-void
-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);
-      last_node->next = current_allocator->free_lists;
-      current_allocator->free_lists = list;
-      G_UNLOCK (current_allocator);
-    }
-}
-
-static inline void
-_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;
-      G_UNLOCK (current_allocator);
-    }
-}
-
-void
-g_list_free_1 (GList *list)
-{
-  _g_list_free_1 (list);
-}
-
-#else /* DISABLE_MEM_POOLS */
-
 #define _g_list_alloc g_list_alloc
 GList*
 g_list_alloc (void)
 {
   GList *list;
   
-  list = g_new0 (GList, 1);
+  list = g_alloc0_chunk (sizeof (GList));
   
   return list;
 }
@@ -217,25 +47,16 @@
 void
 g_list_free (GList *list)
 {
-  GList *last;
-  
-  while (list)
-    {
-      last = list;
-      list = list->next;
-      g_free (last);
-    }
+  g_free_chunk_list (list, sizeof (GList));
 }
 
 #define _g_list_free_1 g_list_free_1
 void
 g_list_free_1 (GList *list)
 {
-  g_free (list);
+  g_free_chunk (list, sizeof (GList));
 }
 
-#endif
-
 GList*
 g_list_append (GList	*list,
 	       gpointer	 data)
@@ -323,7 +144,7 @@
 {
   if (!list)
     {
-      list = g_list_alloc ();
+      list = _g_list_alloc ();
       list->data = data;
       g_return_val_if_fail (sibling == NULL, list);
       return list;
@@ -332,7 +153,7 @@
     {
       GList *node;
 
-      node = g_list_alloc ();
+      node = _g_list_alloc ();
       node->data = data;
       if (sibling->prev)
 	{
@@ -358,7 +179,7 @@
       while (last->next)
 	last = last->next;
 
-      last->next = g_list_alloc ();
+      last->next = _g_list_alloc ();
       last->next->data = data;
       last->next->prev = last;
 
Index: glib/gslist.c
===================================================================
RCS file: /cvs/gnome/glib/glib/gslist.c,v
retrieving revision 1.27
diff -u -r1.27 gslist.c
--- glib/gslist.c	14 Mar 2005 04:26:57 -0000	1.27
+++ glib/gslist.c	26 Sep 2005 03:58:59 -0000
@@ -34,174 +34,13 @@
 #include "galias.h"
 
 
-#ifndef DISABLE_MEM_POOLS
-struct _GAllocator /* from gmem.c */
-{
-  gchar         *name;
-  guint16        n_preallocs;
-  guint          is_unused : 1;
-  guint          type : 4;
-  GAllocator    *last;
-  GMemChunk     *mem_chunk;
-  GSList        *free_lists; /* implementation specific */
-};
-
-G_LOCK_DEFINE_STATIC (current_allocator);
-static GAllocator       *current_allocator = NULL;
-
-/* HOLDS: current_allocator_lock */
-static void
-g_slist_validate_allocator (GAllocator *allocator)
-{
-  g_return_if_fail (allocator != NULL);
-  g_return_if_fail (allocator->is_unused == TRUE);
-
-  if (allocator->type != G_ALLOCATOR_SLIST)
-    {
-      allocator->type = G_ALLOCATOR_SLIST;
-      if (allocator->mem_chunk)
-	{
-	  g_mem_chunk_destroy (allocator->mem_chunk);
-	  allocator->mem_chunk = NULL;
-	}
-    }
-
-  if (!allocator->mem_chunk)
-    {
-      allocator->mem_chunk = g_mem_chunk_new (allocator->name,
-					      sizeof (GSList),
-					      sizeof (GSList) * allocator->n_preallocs,
-					      G_ALLOC_ONLY);
-      allocator->free_lists = NULL;
-    }
-
-  allocator->is_unused = FALSE;
-}
-
-void
-g_slist_push_allocator (GAllocator *allocator)
-{
-  G_LOCK (current_allocator);
-  g_slist_validate_allocator (allocator);
-  allocator->last = current_allocator;
-  current_allocator = allocator;
-  G_UNLOCK (current_allocator);
-}
-
-void
-g_slist_pop_allocator (void)
-{
-  G_LOCK (current_allocator);
-  if (current_allocator)
-    {
-      GAllocator *allocator;
-
-      allocator = current_allocator;
-      current_allocator = allocator->last;
-      allocator->last = NULL;
-      allocator->is_unused = TRUE;
-    }
-  G_UNLOCK (current_allocator);
-}
-
-static inline GSList*
-_g_slist_alloc (void)
-{
-  GSList *list;
-
-  G_LOCK (current_allocator);
-  if (!current_allocator)
-    {
-      GAllocator *allocator = g_allocator_new ("GLib default GSList allocator",
-					       128);
-      g_slist_validate_allocator (allocator);
-      allocator->last = NULL;
-      current_allocator = allocator; 
-    }
-  if (!current_allocator->free_lists)
-    {
-      list = g_chunk_new (GSList, current_allocator->mem_chunk);
-      list->data = NULL;
-    }
-  else
-    {
-      if (current_allocator->free_lists->data)
-	{
-	  list = current_allocator->free_lists->data;
-	  current_allocator->free_lists->data = list->next;
-	  list->data = NULL;
-	}
-      else
-	{
-	  list = current_allocator->free_lists;
-	  current_allocator->free_lists = list->next;
-	}
-    }
-  G_UNLOCK (current_allocator);
-  
-  list->next = NULL;
-
-  return list;
-}
-
-GSList*
-g_slist_alloc (void)
-{
-  return _g_slist_alloc ();
-}
-
-void
-g_slist_free (GSList *list)
-{
-  if (list)
-    {
-      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);
-      last_node->next = current_allocator->free_lists;
-      current_allocator->free_lists = list;
-      G_UNLOCK (current_allocator);
-    }
-}
-
-static inline void
-_g_slist_free_1 (GSList *list)
-{
-  if (list)
-    {
-      list->data = NULL;
-      G_LOCK (current_allocator);
-      list->next = current_allocator->free_lists;
-      current_allocator->free_lists = list;
-      G_UNLOCK (current_allocator);
-    }
-}
-
-void
-g_slist_free_1 (GSList *list)
-{
-  _g_slist_free_1 (list);
-}
-#else /* DISABLE_MEM_POOLS */
-
 #define _g_slist_alloc g_slist_alloc
 GSList*
 g_slist_alloc (void)
 {
   GSList *list;
   
-  list = g_new0 (GSList, 1);
+  list = g_alloc0_chunk (sizeof (GSList));
   
   return list;
 }
@@ -209,24 +48,15 @@
 void
 g_slist_free (GSList *list)
 {
-  GSList *last;
-  
-  while (list)
-    {
-      last = list;
-      list = list->next;
-      g_free (last);
-    }
+  g_free_chunk_list (list, sizeof (GSList));
 }
 
 #define _g_slist_free_1 g_slist_free_1
 void
 g_slist_free_1 (GSList *list)
 {
-  g_free (list);
+  g_free_chunk (list, sizeof (GSList));
 }
-
-#endif
 
 GSList*
 g_slist_append (GSList   *list,
Index: glib/ghash.c
===================================================================
RCS file: /cvs/gnome/glib/glib/ghash.c,v
retrieving revision 1.40
diff -u -r1.40 ghash.c
--- glib/ghash.c	26 Jul 2005 15:49:15 -0000	1.40
+++ glib/ghash.c	26 Sep 2005 03:58:59 -0000
@@ -31,9 +31,11 @@
 #include "config.h"
 
 #include "glib.h"
+#include <stdio.h>
+#undef g_hash_table_new
+#undef g_hash_table_new_full
 #include "galias.h"
 
-
 #define HASH_TABLE_MIN_SIZE 11
 #define HASH_TABLE_MAX_SIZE 13845163
 
@@ -84,13 +86,6 @@
                                                    gboolean        notify);
 
 
-#ifndef DISABLE_MEM_POOLS
-G_LOCK_DEFINE_STATIC (g_hash_global);
-
-static GMemChunk *node_mem_chunk = NULL;
-static GHashNode *node_free_list = NULL;
-#endif
-
 /**
  * g_hash_table_new:
  * @hash_func: a function to create a hash value from a key.
@@ -117,6 +112,26 @@
 }
 
 
+static GList *tables = NULL;
+static void
+dump_tables (void)
+{
+  GList *l;
+  gulong total;
+
+  total = 0;
+  for (l = tables; l; l = l->next)
+    {
+      GHashTable *table = l->data;
+
+      total += table->nnodes;
+      fprintf (stderr, "table %p: %d nodes, size %d\n",
+	       table, table->nnodes, table->size);
+    }
+  
+  g_print ("total number of hash nodes %ld\n", total);
+}
+
 /**
  * g_hash_table_new_full:
  * @hash_func: a function to create a hash value from a key.
@@ -154,7 +169,13 @@
   
   for (i = 0; i < hash_table->size; i++)
     hash_table->nodes[i] = NULL;
-  
+
+#if 0  
+  if (!tables)
+    g_atexit (dump_tables);
+  tables = g_list_prepend (tables, hash_table);
+#endif
+
   return hash_table;
 }
 
@@ -179,7 +200,9 @@
     g_hash_nodes_destroy (hash_table->nodes[i], 
 			  hash_table->key_destroy_func,
 			  hash_table->value_destroy_func);
-  
+
+  tables = g_list_remove (tables, hash_table);
+
   g_free (hash_table->nodes);
   g_free (hash_table);
 }
@@ -651,26 +674,7 @@
 {
   GHashNode *hash_node;
   
-#ifdef DISABLE_MEM_POOLS
-  hash_node = g_new (GHashNode, 1);
-#else
-  G_LOCK (g_hash_global);
-  if (node_free_list)
-    {
-      hash_node = node_free_list;
-      node_free_list = node_free_list->next;
-    }
-  else
-    {
-      if (!node_mem_chunk)
-	node_mem_chunk = g_mem_chunk_new ("hash node mem chunk",
-					  sizeof (GHashNode),
-					  1024, G_ALLOC_ONLY);
-      
-      hash_node = g_chunk_new (GHashNode, node_mem_chunk);
-    }
-  G_UNLOCK (g_hash_global);
-#endif
+  hash_node = (GHashNode *) g_alloc_chunk (sizeof (GHashNode));
   
   hash_node->key = key;
   hash_node->value = value;
@@ -694,14 +698,7 @@
   hash_node->value = NULL;
 #endif /* ENABLE_GC_FRIENDLY */
 
-#ifdef DISABLE_MEM_POOLS
-  g_free (hash_node);
-#else
-  G_LOCK (g_hash_global);
-  hash_node->next = node_free_list;
-  node_free_list = hash_node;
-  G_UNLOCK (g_hash_global);
-#endif
+  g_free_chunk (hash_node, sizeof (GHashNode));
 }
 
 static void
@@ -709,7 +706,6 @@
 		      GFreeFunc  key_destroy_func,
 		      GFreeFunc  value_destroy_func)
 {
-#ifdef DISABLE_MEM_POOLS
   while (hash_node)
     {
       GHashNode *next = hash_node->next;
@@ -719,46 +715,11 @@
       if (value_destroy_func)
 	value_destroy_func (hash_node->value);
 
-      g_free (hash_node);
+      g_free_chunk (hash_node, sizeof (GHashNode));
       hash_node = next;
-    }  
-#else
-  if (hash_node)
-    {
-      GHashNode *node = hash_node;
-  
-      while (node->next)
-	{
-	  if (key_destroy_func)
-	    key_destroy_func (node->key);
-	  if (value_destroy_func)
-	    value_destroy_func (node->value);
-
-#ifdef ENABLE_GC_FRIENDLY
-	  node->key = NULL;
-	  node->value = NULL;
-#endif /* ENABLE_GC_FRIENDLY */
-
-	  node = node->next;
-	}
-
-      if (key_destroy_func)
-	key_destroy_func (node->key);
-      if (value_destroy_func)
-	value_destroy_func (node->value);
-
-#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_UNLOCK (g_hash_global);
-    }
-#endif
+    } 
 }
+
 
 #define __G_HASH_C__
 #include "galiasdef.c"
