? birnan
? carelist
? freelist.patch
? glibpatch
? hmm
? inlinefix.patch
? remo.patch
? ssp-configure.in
? glib/bs.patch
? glib/chunk.patch
? glib/core.20865
? glib/core.21445
? glib/core.22595
? glib/core.22596
? glib/core.22679
? glib/freelist.patch
? glib/gfreelist.c
? glib/gfreelist.h
? glib/gmain.ac
? glib/gmem.c.crack-mempools
? glib/gmem.c.original
? glib/gmemchunk.loT
? glib/hmm
? glib/psp.patch
? gobject/adf
? gobject/asdf
? gobject/cachecheck
? gobject/cachecheck.sorted
? gobject/core.2789
? gobject/core.2790
? gobject/core.2791
? gobject/core.5928
? gobject/core.6656
? gobject/core.7018
? gobject/core.8095
? gobject/core.9314
? gobject/core.9688
? gobject/doublepsp.patch
? gobject/gparam.hack.ssp
? gobject/gtype.s
? gobject/instan.patch
? gobject/instantiable.patch
? gobject/l33t.patch
? gobject/leet.diff
? gobject/newpsp.patch
? gobject/noop.patc
? gobject/objdiff
? gobject/opti
? gobject/optihead
? gobject/optimize.patch
? gobject/psp.patch
? gobject/psp2.patc
? gobject/signal
? gobject/signalpatch.timj
? gobject/sigpatch
? gobject/trivial.patch
? gobject/typecheckcache.patch
? gobject/typechecks
? gobject/typehack.patch
? gobject/typesort
? gobject/uninline.patch
? tests/core.6691
Index: glib/Makefile.am
===================================================================
RCS file: /cvs/gnome/glib/glib/Makefile.am,v
retrieving revision 1.106
diff -u -p -u -r1.106 Makefile.am
--- glib/Makefile.am	4 Mar 2003 10:10:31 -0000	1.106
+++ glib/Makefile.am	27 Jul 2003 20:45:07 -0000
@@ -55,6 +55,8 @@ libglib_2_0_la_SOURCES = 	\
 	gdir.c			\
 	gerror.c		\
 	gfileutils.c		\
+	gfreelist.c		\
+	gfreelist.h		\
 	ghash.c			\
 	ghook.c			\
 	giochannel.c    	\
@@ -121,6 +123,7 @@ glibsubinclude_HEADERS =   \
 	gdir.h		\
 	gerror.h	\
 	gfileutils.h	\
+	gfreelist.h	\
 	ghash.h		\
 	ghook.h		\
 	giochannel.h	\
Index: glib/garray.c
===================================================================
RCS file: /cvs/gnome/glib/glib/garray.c,v
retrieving revision 1.29
diff -u -p -u -r1.29 garray.c
--- glib/garray.c	26 Jul 2003 08:03:14 -0000	1.29
+++ glib/garray.c	27 Jul 2003 20:45:08 -0000
@@ -62,8 +62,8 @@ static gint g_nearest_pow        (gint  
 static void g_array_maybe_expand (GRealArray *array,
 				  gint        len);
 
-static GMemChunk *array_mem_chunk = NULL;
-G_LOCK_DEFINE_STATIC (array_mem_chunk);
+G_LOCK_DEFINE_STATIC (array_lock);
+G_FREE_LIST_DEFINE_STATIC (array_free_list, sizeof (GRealArray), 16);
 
 GArray*
 g_array_new (gboolean zero_terminated,
@@ -73,21 +73,17 @@ g_array_new (gboolean zero_terminated,
   return (GArray*) g_array_sized_new (zero_terminated, clear, elt_size, 0);
 }
 
-GArray* g_array_sized_new (gboolean zero_terminated,
-			   gboolean clear,
-			   guint    elt_size,
-			   guint    reserved_size)
+GArray*
+g_array_sized_new (gboolean zero_terminated,
+		   gboolean clear,
+		   guint    elt_size,
+		   guint    reserved_size)
 {
   GRealArray *array;
 
-  G_LOCK (array_mem_chunk);
-  if (!array_mem_chunk)
-    array_mem_chunk = g_mem_chunk_new ("array mem chunk",
-				       sizeof (GRealArray),
-				       1024, G_ALLOC_AND_FREE);
-
-  array = g_chunk_new (GRealArray, array_mem_chunk);
-  G_UNLOCK (array_mem_chunk);
+  G_LOCK (array_lock);
+  array = G_FREE_LIST_ALLOC (array_free_list);
+  G_UNLOCK (array_lock);
 
   array->data            = NULL;
   array->len             = 0;
@@ -121,9 +117,9 @@ g_array_free (GArray  *array,
   else
     segment = array->data;
 
-  G_LOCK (array_mem_chunk);
-  g_mem_chunk_free (array_mem_chunk, array);
-  G_UNLOCK (array_mem_chunk);
+  G_LOCK (array_lock);
+  G_FREE_LIST_FREE (array_free_list, array);
+  G_UNLOCK (array_lock);
 
   return segment;
 }
@@ -372,9 +368,8 @@ struct _GRealPtrArray
 static void g_ptr_array_maybe_expand (GRealPtrArray *array,
 				      gint           len);
 
-static GMemChunk *ptr_array_mem_chunk = NULL;
-G_LOCK_DEFINE_STATIC (ptr_array_mem_chunk);
-
+G_LOCK_DEFINE_STATIC (ptr_array_lock);
+G_FREE_LIST_DEFINE_STATIC (ptr_array_free_list, sizeof (GRealPtrArray), 16);
 
 GPtrArray*
 g_ptr_array_new (void)
@@ -387,14 +382,9 @@ g_ptr_array_sized_new (guint reserved_si
 {
   GRealPtrArray *array;
 
-  G_LOCK (ptr_array_mem_chunk);
-  if (!ptr_array_mem_chunk)
-    ptr_array_mem_chunk = g_mem_chunk_new ("array mem chunk",
-					   sizeof (GRealPtrArray),
-					   1024, G_ALLOC_AND_FREE);
-
-  array = g_chunk_new (GRealPtrArray, ptr_array_mem_chunk);
-  G_UNLOCK (ptr_array_mem_chunk);
+  G_LOCK (ptr_array_lock);
+  array = G_FREE_LIST_ALLOC (ptr_array_free_list);
+  G_UNLOCK (ptr_array_lock);
 
   array->pdata = NULL;
   array->len = 0;
@@ -422,9 +412,9 @@ g_ptr_array_free (GPtrArray   *array,
   else
     segment = array->pdata;
 
-  G_LOCK (ptr_array_mem_chunk);
-  g_mem_chunk_free (ptr_array_mem_chunk, array);
-  G_UNLOCK (ptr_array_mem_chunk);
+  G_LOCK (ptr_array_lock);
+  G_FREE_LIST_FREE (ptr_array_free_list, array);
+  G_UNLOCK (ptr_array_lock);
 
   return segment;
 }
Index: glib/gcache.c
===================================================================
RCS file: /cvs/gnome/glib/glib/gcache.c,v
retrieving revision 1.12
diff -u -p -u -r1.12 gcache.c
--- glib/gcache.c	4 Dec 2002 01:27:43 -0000	1.12
+++ glib/gcache.c	27 Jul 2003 20:45:08 -0000
@@ -67,9 +67,8 @@ struct _GCache
 static GCacheNode* g_cache_node_new     (gpointer value);
 static void        g_cache_node_destroy (GCacheNode *node);
 
-
-static GMemChunk *node_mem_chunk = NULL;
-G_LOCK_DEFINE_STATIC (node_mem_chunk);
+G_LOCK_DEFINE_STATIC (node_lock);
+G_FREE_LIST_DEFINE_STATIC (node_free_list, sizeof (GCacheNode), 64);
 
 GCache*
 g_cache_new (GCacheNewFunc      value_new_func,
@@ -191,13 +190,9 @@ g_cache_node_new (gpointer value)
 {
   GCacheNode *node;
 
-  G_LOCK (node_mem_chunk);
-  if (!node_mem_chunk)
-    node_mem_chunk = g_mem_chunk_new ("cache node mem chunk", sizeof (GCacheNode),
-				      1024, G_ALLOC_AND_FREE);
-
-  node = g_chunk_new (GCacheNode, node_mem_chunk);
-  G_UNLOCK (node_mem_chunk);
+  G_LOCK (node_lock);
+  node = G_FREE_LIST_ALLOC (node_free_list);
+  G_UNLOCK (node_lock);
 
   node->value = value;
   node->ref_count = 1;
@@ -208,7 +203,7 @@ g_cache_node_new (gpointer value)
 static void
 g_cache_node_destroy (GCacheNode *node)
 {
-  G_LOCK (node_mem_chunk);
-  g_mem_chunk_free (node_mem_chunk, node);
-  G_UNLOCK (node_mem_chunk);
+  G_LOCK (node_lock);
+  G_FREE_LIST_FREE (node_free_list, node);
+  G_UNLOCK (node_lock);
 }
Index: glib/gdataset.c
===================================================================
RCS file: /cvs/gnome/glib/glib/gdataset.c,v
retrieving revision 1.19
diff -u -p -u -r1.19 gdataset.c
--- glib/gdataset.c	4 Dec 2002 01:27:43 -0000	1.19
+++ glib/gdataset.c	27 Jul 2003 20:45:09 -0000
@@ -40,9 +40,9 @@
 
 /* --- defines --- */
 #define	G_QUARK_BLOCK_SIZE			(512)
-#define	G_DATA_MEM_CHUNK_PREALLOC		(128)
+#define	G_DATA_PREALLOC				(128)
 #define	G_DATA_CACHE_MAX			(512)
-#define	G_DATASET_MEM_CHUNK_PREALLOC		(32)
+#define	G_DATASET_PREALLOC			(32)
 
 
 /* --- structures --- */
@@ -80,8 +80,11 @@ G_LOCK_DEFINE_STATIC (g_dataset_global);
 static GHashTable   *g_dataset_location_ht = NULL;
 static GDataset     *g_dataset_cached = NULL; /* should this be
 						 threadspecific? */
-static GMemChunk    *g_dataset_mem_chunk = NULL;
-static GMemChunk    *g_data_mem_chunk = NULL;
+
+G_FREE_LIST_DEFINE_STATIC (g_dataset_free_list,
+			   sizeof (GDataset), G_DATASET_PREALLOC);
+G_FREE_LIST_DEFINE_STATIC (g_data_free_list,
+			   sizeof (GData), G_DATA_PREALLOC);
 static GData	    *g_data_cache = NULL;
 static guint	     g_data_cache_length = 0;
 
@@ -125,7 +128,7 @@ g_datalist_clear_i (GData **datalist)
 	  g_data_cache_length++;
 	}
       else
-	g_mem_chunk_free (g_data_mem_chunk, prev);
+	G_FREE_LIST_FREE (g_data_free_list, prev);
     }
 }
 
@@ -173,7 +176,7 @@ g_dataset_destroy_internal (GDataset *da
 	  if (dataset == g_dataset_cached)
 	    g_dataset_cached = NULL;
 	  g_hash_table_remove (g_dataset_location_ht, dataset_location);
-	  g_mem_chunk_free (g_dataset_mem_chunk, dataset);
+	  G_FREE_LIST_FREE (g_dataset_free_list, dataset);
 	  break;
 	}
       
@@ -256,7 +259,7 @@ g_data_set_internal (GData	  **datalist,
 		  g_data_cache_length++;
 		}
 	      else
-		g_mem_chunk_free (g_data_mem_chunk, list);
+		G_FREE_LIST_FREE (g_data_free_list, list);
 	      
 	      return ret_data;
 	    }
@@ -307,7 +310,7 @@ g_data_set_internal (GData	  **datalist,
 	  g_data_cache_length--;
 	}
       else
-	list = g_chunk_new (GData, g_data_mem_chunk);
+	list = G_FREE_LIST_ALLOC (g_data_free_list);
       list->next = *datalist;
       list->id = key_id;
       list->data = data;
@@ -344,7 +347,7 @@ g_dataset_id_set_data_full (gconstpointe
   dataset = g_dataset_lookup (dataset_location);
   if (!dataset)
     {
-      dataset = g_chunk_new (GDataset, g_dataset_mem_chunk);
+      dataset = G_FREE_LIST_ALLOC (g_dataset_free_list);
       dataset->location = dataset_location;
       g_datalist_init (&dataset->datalist);
       g_hash_table_insert (g_dataset_location_ht, 
@@ -531,16 +534,6 @@ g_data_initialize (void)
 
   g_dataset_location_ht = g_hash_table_new (g_direct_hash, NULL);
   g_dataset_cached = NULL;
-  g_dataset_mem_chunk =
-    g_mem_chunk_new ("GDataset MemChunk",
-		     sizeof (GDataset),
-		     sizeof (GDataset) * G_DATASET_MEM_CHUNK_PREALLOC,
-		     G_ALLOC_AND_FREE);
-  g_data_mem_chunk =
-    g_mem_chunk_new ("GData MemChunk",
-		     sizeof (GData),
-		     sizeof (GData) * G_DATA_MEM_CHUNK_PREALLOC,
-		     G_ALLOC_AND_FREE);
 }
 
 GQuark
Index: glib/ghash.c
===================================================================
RCS file: /cvs/gnome/glib/glib/ghash.c,v
retrieving revision 1.34
diff -u -p -u -r1.34 ghash.c
--- glib/ghash.c	4 Dec 2002 01:27:43 -0000	1.34
+++ glib/ghash.c	27 Jul 2003 20:45:10 -0000
@@ -85,9 +85,7 @@ static guint g_hash_table_foreach_remove
 
 #ifndef DISABLE_MEM_POOLS
 G_LOCK_DEFINE_STATIC (g_hash_global);
-
-static GMemChunk *node_mem_chunk = NULL;
-static GHashNode *node_free_list = NULL;
+G_FREE_LIST_DEFINE_STATIC (g_hash_free_list, sizeof (GHashNode), 1024);
 #endif
 
 /**
@@ -616,20 +614,7 @@ g_hash_node_new (gpointer key,
   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);
-    }
+  hash_node = G_FREE_LIST_ALLOC (g_hash_free_list);
   G_UNLOCK (g_hash_global);
 #endif
   
@@ -659,8 +644,7 @@ g_hash_node_destroy (GHashNode      *has
   g_free (hash_node);
 #else
   G_LOCK (g_hash_global);
-  hash_node->next = node_free_list;
-  node_free_list = hash_node;
+  G_FREE_LIST_FREE (g_hash_free_list, hash_node);
   G_UNLOCK (g_hash_global);
 #endif
 }
@@ -714,8 +698,7 @@ g_hash_nodes_destroy (GHashNode *hash_no
 #endif /* ENABLE_GC_FRIENDLY */
  
       G_LOCK (g_hash_global);
-      node->next = node_free_list;
-      node_free_list = hash_node;
+      G_FREE_LIST_FREE (g_hash_free_list, hash_node);
       G_UNLOCK (g_hash_global);
     }
 #endif
Index: glib/ghook.c
===================================================================
RCS file: /cvs/gnome/glib/glib/ghook.c,v
retrieving revision 1.22
diff -u -p -u -r1.22 ghook.c
--- glib/ghook.c	4 Dec 2002 01:27:43 -0000	1.22
+++ glib/ghook.c	27 Jul 2003 20:45:11 -0000
@@ -32,7 +32,7 @@
  */
 
 #include "config.h"
-
+#undef G_DISABLE_DEPRECATED
 #include "glib.h"
 
 
Index: glib/ghook.h
===================================================================
RCS file: /cvs/gnome/glib/glib/ghook.h,v
retrieving revision 1.6
diff -u -p -u -r1.6 ghook.h
--- glib/ghook.h	6 Feb 2003 19:57:14 -0000	1.6
+++ glib/ghook.h	27 Jul 2003 20:45:11 -0000
@@ -27,11 +27,8 @@
 #ifndef __G_HOOK_H__
 #define __G_HOOK_H__
 
-#include <glib/gmem.h>
-
 G_BEGIN_DECLS
 
-
 /* --- typedefs --- */
 typedef struct _GHook		GHook;
 typedef struct _GHookList	GHookList;
@@ -60,13 +57,13 @@ typedef enum
 /* --- structures --- */
 struct _GHookList
 {
-  gulong	    seq_id;
-  guint		    hook_size : 16;
-  guint		    is_setup : 1;
-  GHook		   *hooks;
-  GMemChunk	   *hook_memchunk;
-  GHookFinalizeFunc finalize_hook;
-  gpointer	    dummy[2];
+  gulong		seq_id;
+  guint			hook_size : 16;
+  guint			is_setup : 1;
+  GHook	*		hooks;
+  struct _GMemChunk *	hook_memchunk;
+  GHookFinalizeFunc	finalize_hook;
+  gpointer		dummy[2];
 };
 struct _GHook
 {
Index: glib/glib.h
===================================================================
RCS file: /cvs/gnome/glib/glib/glib.h,v
retrieving revision 1.218
diff -u -p -u -r1.218 glib.h
--- glib/glib.h	5 Nov 2001 01:47:31 -0000	1.218
+++ glib/glib.h	27 Jul 2003 20:45:11 -0000
@@ -39,6 +39,7 @@
 #include <glib/gdir.h>
 #include <glib/gerror.h>
 #include <glib/gfileutils.h>
+#include <glib/gfreelist.h>
 #include <glib/ghash.h>
 #include <glib/ghook.h>
 #include <glib/giochannel.h>
Index: glib/glist.c
===================================================================
RCS file: /cvs/gnome/glib/glib/glist.c,v
retrieving revision 1.28
diff -u -p -u -r1.28 glist.c
--- glib/glist.c	19 May 2003 17:02:32 -0000	1.28
+++ glib/glist.c	27 Jul 2003 20:45:12 -0000
@@ -41,8 +41,7 @@ struct _GAllocator /* from gmem.c */
   guint          is_unused : 1;
   guint          type : 4;
   GAllocator    *last;
-  GMemChunk     *mem_chunk;
-  GList		*free_lists; /* implementation specific */
+  GFreeList	*free_list;
 };
 
 static GAllocator	*current_allocator = NULL;
@@ -58,20 +57,17 @@ g_list_validate_allocator (GAllocator *a
   if (allocator->type != G_ALLOCATOR_LIST)
     {
       allocator->type = G_ALLOCATOR_LIST;
-      if (allocator->mem_chunk)
+      if (allocator->free_list)
 	{
-	  g_mem_chunk_destroy (allocator->mem_chunk);
-	  allocator->mem_chunk = NULL;
+	  g_free_list_destroy (allocator->free_list);
+	  allocator->free_list = NULL;
 	}
     }
 
-  if (!allocator->mem_chunk)
+  if (!allocator->free_list)
     {
-      allocator->mem_chunk = g_mem_chunk_new (allocator->name,
-					      sizeof (GList),
-					      sizeof (GList) * allocator->n_preallocs,
-					      G_ALLOC_ONLY);
-      allocator->free_lists = NULL;
+      allocator->free_list =
+	g_free_list_new (sizeof (GList), allocator->n_preallocs);
     }
 
   allocator->is_unused = FALSE;
@@ -109,7 +105,7 @@ _g_list_alloc (void)
   GList *list;
 
   G_LOCK (current_allocator);
-  if (!current_allocator)
+  if (G_UNLIKELY (!current_allocator))
     {
       GAllocator *allocator = g_allocator_new ("GLib default GList allocator",
 					       128);
@@ -117,26 +113,10 @@ _g_list_alloc (void)
       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;
-	}
-    }
+  list = g_free_list_alloc (current_allocator->free_list);
   G_UNLOCK (current_allocator);
+
+  list->data = NULL;
   list->next = NULL;
   list->prev = NULL;
   
@@ -152,27 +132,20 @@ g_list_alloc (void)
 void
 g_list_free (GList *list)
 {
-  if (list)
+  while (list)
     {
-      GList *last_node = list;
-
+      GList *next = list->next;
+      
 #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 */
-
+      list->data = NULL;
+      list->prev = NULL;
+      list->next = NULL;
+#endif
       G_LOCK (current_allocator);
-      last_node->next = current_allocator->free_lists;
-      current_allocator->free_lists = list;
+      g_free_list_free (current_allocator->free_list, list);
       G_UNLOCK (current_allocator);
+
+      list = next;
     }
 }
 
@@ -181,15 +154,14 @@ _g_list_free_1 (GList *list)
 {
   if (list)
     {
-      list->data = NULL;  
-
 #ifdef ENABLE_GC_FRIENDLY
-      list->prev = NULL;  
+      list->prev = NULL;
+      list->next = NULL;
+      list->data = NULL;
 #endif /* ENABLE_GC_FRIENDLY */
 
       G_LOCK (current_allocator);
-      list->next = current_allocator->free_lists;
-      current_allocator->free_lists = list;
+      g_free_list_free (current_allocator->free_list, list);
       G_UNLOCK (current_allocator);
     }
 }
Index: glib/gmain.c
===================================================================
RCS file: /cvs/gnome/glib/glib/gmain.c,v
retrieving revision 1.97
diff -u -p -u -r1.97 gmain.c
--- glib/gmain.c	25 Jul 2003 21:32:47 -0000	1.97
+++ glib/gmain.c	27 Jul 2003 20:45:18 -0000
@@ -107,8 +107,7 @@ struct _GMainContext
   gint in_check_or_prepare;
 
   GPollRec *poll_records;
-  GPollRec *poll_free_list;
-  GMemChunk *poll_chunk;
+  GFreeList *poll_free_list;
   guint n_poll_records;
   GPollFD *cached_poll_array;
   guint cached_poll_array_size;
@@ -577,8 +576,8 @@ g_main_context_unref_and_unlock (GMainCo
   g_ptr_array_free (context->pending_dispatches, TRUE);
   g_free (context->cached_poll_array);
  
-  if (context->poll_chunk) 
-    g_mem_chunk_destroy (context->poll_chunk);
+  if (context->poll_free_list) 
+    g_free_list_destroy (context->poll_free_list);
 
 #ifdef G_THREADS_ENABLED
   if (g_thread_supported())
@@ -2755,16 +2754,10 @@ g_main_context_add_poll_unlocked (GMainC
 {
   GPollRec *lastrec, *pollrec, *newrec;
 
-  if (!context->poll_chunk)
-    context->poll_chunk = g_mem_chunk_create (GPollRec, 32, G_ALLOC_ONLY);
+  if (!context->poll_free_list)
+    context->poll_free_list = g_free_list_new (sizeof (GPollRec), 32);
 
-  if (context->poll_free_list)
-    {
-      newrec = context->poll_free_list;
-      context->poll_free_list = newrec->next;
-    }
-  else
-    newrec = g_chunk_new (GPollRec, context->poll_chunk);
+  newrec = g_free_list_alloc (context->poll_free_list);
 
   /* This file descriptor may be checked before we ever poll */
   fd->revents = 0;
@@ -2841,8 +2834,7 @@ g_main_context_remove_poll_unlocked (GMa
 	  pollrec->fd = NULL;  
 #endif /* ENABLE_GC_FRIENDLY */
 
-	  pollrec->next = context->poll_free_list;
-	  context->poll_free_list = pollrec;
+	  g_free_list_free (context->poll_free_list, pollrec);
 
 	  context->n_poll_records--;
 	  break;
Index: glib/gmem.c
===================================================================
RCS file: /cvs/gnome/glib/glib/gmem.c,v
retrieving revision 1.42
diff -u -p -u -r1.42 gmem.c
--- glib/gmem.c	25 Jul 2003 21:32:47 -0000	1.42
+++ glib/gmem.c	27 Jul 2003 20:45:19 -0000
@@ -34,6 +34,7 @@
 #include <string.h>
 #include <signal.h>
 
+#undef G_DISABLE_DEPRECATED
 #include "glib.h"
 #include "gthreadinit.h"
 
@@ -1214,8 +1215,7 @@ struct _GAllocator /* from gmem.c */
   guint		 is_unused : 1;
   guint		 type : 4;
   GAllocator	*last;
-  GMemChunk	*mem_chunk;
-  gpointer	 dummy; /* implementation specific */
+  GFreeList     *free_list;
 };
 
 GAllocator*
@@ -1232,8 +1232,7 @@ g_allocator_new (const gchar *name,
   allocator->is_unused = TRUE;
   allocator->type = 0;
   allocator->last = NULL;
-  allocator->mem_chunk = NULL;
-  allocator->dummy = NULL;
+  allocator->free_list = NULL;
 
   return allocator;
 }
@@ -1245,8 +1244,8 @@ g_allocator_free (GAllocator *allocator)
   g_return_if_fail (allocator->is_unused == TRUE);
 
   g_free (allocator->name);
-  if (allocator->mem_chunk)
-    g_mem_chunk_destroy (allocator->mem_chunk);
+  if (allocator->free_list)
+    g_free_list_destroy (allocator->free_list);
 
   g_free (allocator);
 }
Index: glib/gmem.h
===================================================================
RCS file: /cvs/gnome/glib/glib/gmem.h,v
retrieving revision 1.9
diff -u -p -u -r1.9 gmem.h
--- glib/gmem.h	6 Feb 2003 19:57:14 -0000	1.9
+++ glib/gmem.h	27 Jul 2003 20:45:19 -0000
@@ -32,9 +32,11 @@
 G_BEGIN_DECLS
 
 typedef struct _GAllocator GAllocator;
-typedef struct _GMemChunk  GMemChunk;
 typedef struct _GMemVTable GMemVTable;
 
+#ifndef G_DISABLE_DEPRECATED
+
+typedef struct _GMemChunk  GMemChunk;
 
 #if GLIB_SIZEOF_VOID_P > GLIB_SIZEOF_LONG
 #  define G_MEM_ALIGN	GLIB_SIZEOF_VOID_P
@@ -42,6 +44,7 @@ typedef struct _GMemVTable GMemVTable;
 #  define G_MEM_ALIGN	GLIB_SIZEOF_LONG
 #endif	/* GLIB_SIZEOF_VOID_P <= GLIB_SIZEOF_LONG */
 
+#endif
 
 /* Memory allocation functions
  */
@@ -91,6 +94,23 @@ GLIB_VAR GMemVTable	*glib_mem_profiler_t
 void	g_mem_profile	(void);
 
 
+/* Generic allocators
+ */
+GAllocator* g_allocator_new   (const gchar  *name,
+			       guint         n_preallocs);
+void        g_allocator_free  (GAllocator   *allocator);
+
+/* internal */
+#define	G_ALLOCATOR_LIST	(1)
+#define	G_ALLOCATOR_SLIST	(2)
+#define	G_ALLOCATOR_NODE	(3)
+
+
+
+/* Deprecated memchunks */
+
+#ifndef G_DISABLE_DEPRECATED
+
 /* Memchunk convenience functions
  */
 #define g_mem_chunk_create(type, pre_alloc, alloc_type)	( \
@@ -156,17 +176,7 @@ void       g_mem_chunk_info    (void);
  */
 void	   g_blow_chunks (void);
 
-
-/* Generic allocators
- */
-GAllocator* g_allocator_new   (const gchar  *name,
-			       guint         n_preallocs);
-void        g_allocator_free  (GAllocator   *allocator);
-
-/* internal */
-#define	G_ALLOCATOR_LIST	(1)
-#define	G_ALLOCATOR_SLIST	(2)
-#define	G_ALLOCATOR_NODE	(3)
+#endif /* G_DISABLE_DEPRECATED */
 
 
 G_END_DECLS
Index: glib/gnode.c
===================================================================
RCS file: /cvs/gnome/glib/glib/gnode.c,v
retrieving revision 1.18
diff -u -p -u -r1.18 gnode.c
--- glib/gnode.c	4 Dec 2002 01:27:43 -0000	1.18
+++ glib/gnode.c	27 Jul 2003 20:45:20 -0000
@@ -45,8 +45,7 @@ struct _GAllocator /* from gmem.c */
   guint          is_unused : 1;
   guint          type : 4;
   GAllocator    *last;
-  GMemChunk     *mem_chunk;
-  GNode         *free_nodes; /* implementation specific */
+  GFreeList	*free_list;
 };
 
 G_LOCK_DEFINE_STATIC (current_allocator);
@@ -62,20 +61,17 @@ g_node_validate_allocator (GAllocator *a
   if (allocator->type != G_ALLOCATOR_NODE)
     {
       allocator->type = G_ALLOCATOR_NODE;
-      if (allocator->mem_chunk)
+      if (allocator->free_list)
 	{
-	  g_mem_chunk_destroy (allocator->mem_chunk);
-	  allocator->mem_chunk = NULL;
+	  g_free_list_destroy (allocator->free_list);
+	  allocator->free_list = NULL;
 	}
     }
 
-  if (!allocator->mem_chunk)
+  if (!allocator->free_list)
     {
-      allocator->mem_chunk = g_mem_chunk_new (allocator->name,
-					      sizeof (GNode),
-					      sizeof (GNode) * allocator->n_preallocs,
-					      G_ALLOC_ONLY);
-      allocator->free_nodes = NULL;
+      allocator->free_list = 
+	g_free_list_new (sizeof (GNode), allocator->n_preallocs);
     }
 
   allocator->is_unused = FALSE;
@@ -123,13 +119,7 @@ g_node_new (gpointer data)
        allocator->last = NULL;
        current_allocator = allocator;
     }
-  if (!current_allocator->free_nodes)
-    node = g_chunk_new (GNode, current_allocator->mem_chunk);
-  else
-    {
-      node = current_allocator->free_nodes;
-      current_allocator->free_nodes = node->next;
-    }
+  node = g_free_list_alloc (current_allocator->free_list);
   G_UNLOCK (current_allocator);
   
   node->data = data;
@@ -166,8 +156,7 @@ g_nodes_free (GNode *node)
     }
   
   G_LOCK (current_allocator);
-  parent->next = current_allocator->free_nodes;
-  current_allocator->free_nodes = node;
+  g_free_list_free (current_allocator->free_list, parent);
   G_UNLOCK (current_allocator);
 }
 #else /* DISABLE_MEM_POOLS */
Index: glib/gqueue.c
===================================================================
RCS file: /cvs/gnome/glib/glib/gqueue.c,v
retrieving revision 1.12
diff -u -p -u -r1.12 gqueue.c
--- glib/gqueue.c	4 Dec 2002 01:27:43 -0000	1.12
+++ glib/gqueue.c	27 Jul 2003 20:45:20 -0000
@@ -28,10 +28,8 @@
 
 #include "glib.h"
 
-
-G_LOCK_DEFINE_STATIC (queue_memchunk);
-static GMemChunk   *queue_memchunk = NULL;
-static GTrashStack *free_queue_nodes = NULL;
+G_LOCK_DEFINE_STATIC (queue_global);
+G_FREE_LIST_DEFINE_STATIC (queue_free_list, sizeof (GQueue), 16);
 
 /**
  * g_queue_new:
@@ -45,19 +43,9 @@ g_queue_new (void)
 {
   GQueue *queue;
 
-  G_LOCK (queue_memchunk);
-  queue = g_trash_stack_pop (&free_queue_nodes);
-
-  if (!queue)
-    {
-      if (!queue_memchunk)
-	queue_memchunk = g_mem_chunk_new ("GLib GQueue chunk",
-					  sizeof (GNode),
-					  sizeof (GNode) * 128,
-					  G_ALLOC_ONLY);
-      queue = g_chunk_new (GQueue, queue_memchunk);
-    }
-  G_UNLOCK (queue_memchunk);
+  G_LOCK (queue_global);
+  queue = G_FREE_LIST_ALLOC (queue_free_list);
+  G_UNLOCK (queue_global);
 
   queue->head = NULL;
   queue->tail = NULL;
@@ -84,9 +72,9 @@ g_queue_free (GQueue *queue)
   queue->tail = NULL;
 #endif /* ENABLE_GC_FRIENDLY */
 
-  G_LOCK (queue_memchunk);
-  g_trash_stack_push (&free_queue_nodes, queue);
-  G_UNLOCK (queue_memchunk);
+  G_LOCK (queue_global);
+  G_FREE_LIST_FREE (queue_free_list, queue);
+  G_UNLOCK (queue_global);
 }
 
 /**
Index: glib/grel.c
===================================================================
RCS file: /cvs/gnome/glib/glib/grel.c,v
retrieving revision 1.14
diff -u -p -u -r1.14 grel.c
--- glib/grel.c	4 Dec 2002 01:27:43 -0000	1.14
+++ glib/grel.c	27 Jul 2003 20:45:20 -0000
@@ -44,7 +44,7 @@ struct _GRelation
   
   GHashTable   *all_tuples;
   GHashTable  **hashed_tuple_tables;
-  GMemChunk    *tuple_chunk;
+  GFreeList    *tuple_free_list;
   
   gint count;
 };
@@ -108,10 +108,7 @@ g_relation_new (gint fields)
   GRelation* rel = g_new0 (GRelation, 1);
   
   rel->fields = fields;
-  rel->tuple_chunk = g_mem_chunk_new ("Relation Chunk",
-				      fields * sizeof (gpointer),
-				      fields * sizeof (gpointer) * 128,
-				      G_ALLOC_AND_FREE);
+  rel->tuple_free_list = g_free_list_new (fields * sizeof (gpointer), 128);
   rel->all_tuples = g_hash_table_new (tuple_hash (fields), tuple_equal (fields));
   rel->hashed_tuple_tables = g_new0 (GHashTable*, fields);
   
@@ -132,7 +129,7 @@ g_relation_destroy (GRelation *relation)
   if (relation)
     {
       g_hash_table_destroy (relation->all_tuples);
-      g_mem_chunk_destroy (relation->tuple_chunk);
+      g_free_list_destroy (relation->tuple_free_list);
       
       for (i = 0; i < relation->fields; i += 1)
 	{
@@ -165,7 +162,7 @@ void
 g_relation_insert (GRelation   *relation,
 		   ...)
 {
-  gpointer* tuple = g_chunk_new (gpointer, relation->tuple_chunk);
+  gpointer* tuple = g_free_list_alloc (relation->tuple_free_list);
   va_list args;
   gint i;
   
@@ -340,7 +337,7 @@ g_relation_count (GRelation     *relatio
 gboolean
 g_relation_exists (GRelation   *relation, ...)
 {
-  gpointer* tuple = g_chunk_new (gpointer, relation->tuple_chunk);
+  gpointer* tuple = g_free_list_alloc (relation->tuple_free_list);
   va_list args;
   gint i;
   gboolean result;
@@ -354,7 +351,7 @@ g_relation_exists (GRelation   *relation
   
   result = g_hash_table_lookup (relation->all_tuples, tuple) != NULL;
   
-  g_mem_chunk_free (relation->tuple_chunk, tuple);
+  g_free_list_free (relation->tuple_free_list, tuple);
   
   return result;
 }
Index: glib/gslist.c
===================================================================
RCS file: /cvs/gnome/glib/glib/gslist.c,v
retrieving revision 1.25
diff -u -p -u -r1.25 gslist.c
--- glib/gslist.c	4 Dec 2002 01:27:43 -0000	1.25
+++ glib/gslist.c	27 Jul 2003 20:45:21 -0000
@@ -41,8 +41,7 @@ struct _GAllocator /* from gmem.c */
   guint          is_unused : 1;
   guint          type : 4;
   GAllocator    *last;
-  GMemChunk     *mem_chunk;
-  GSList        *free_lists; /* implementation specific */
+  GFreeList	*free_list;
 };
 
 G_LOCK_DEFINE_STATIC (current_allocator);
@@ -58,20 +57,17 @@ g_slist_validate_allocator (GAllocator *
   if (allocator->type != G_ALLOCATOR_SLIST)
     {
       allocator->type = G_ALLOCATOR_SLIST;
-      if (allocator->mem_chunk)
+      if (allocator->free_list)
 	{
-	  g_mem_chunk_destroy (allocator->mem_chunk);
-	  allocator->mem_chunk = NULL;
+	  g_free_list_destroy (allocator->free_list);
+	  allocator->free_list = NULL;
 	}
     }
 
-  if (!allocator->mem_chunk)
+  if (!allocator->free_list)
     {
-      allocator->mem_chunk = g_mem_chunk_new (allocator->name,
-					      sizeof (GSList),
-					      sizeof (GSList) * allocator->n_preallocs,
-					      G_ALLOC_ONLY);
-      allocator->free_lists = NULL;
+      allocator->free_list =
+	g_free_list_new (sizeof (GSList), allocator->n_preallocs);
     }
 
   allocator->is_unused = FALSE;
@@ -109,7 +105,7 @@ _g_slist_alloc (void)
   GSList *list;
 
   G_LOCK (current_allocator);
-  if (!current_allocator)
+  if (G_UNLIKELY (!current_allocator))
     {
       GAllocator *allocator = g_allocator_new ("GLib default GSList allocator",
 					       128);
@@ -117,29 +113,12 @@ _g_slist_alloc (void)
       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;
-	}
-    }
+  list = g_free_list_alloc (current_allocator->free_list);
   G_UNLOCK (current_allocator);
-  
-  list->next = NULL;
 
+  list->data = NULL;
+  list->next = NULL;
+  
   return list;
 }
 
@@ -152,25 +131,18 @@ g_slist_alloc (void)
 void
 g_slist_free (GSList *list)
 {
-  if (list)
+  while (list)
     {
-      GSList *last_node = list;
-  
+      GSList *next = list->next;
+      
 #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 */
-	
+      list->data = NULL;
+#endif
       G_LOCK (current_allocator);
-      last_node->next = current_allocator->free_lists;
-      current_allocator->free_lists = list;
+      g_free_list_free (current_allocator->free_list, list);
       G_UNLOCK (current_allocator);
+
+      list = next;
     }
 }
 
@@ -179,10 +151,11 @@ _g_slist_free_1 (GSList *list)
 {
   if (list)
     {
+#ifdef ENABLE_GC_FRIENDLY
       list->data = NULL;
+#endif
       G_LOCK (current_allocator);
-      list->next = current_allocator->free_lists;
-      current_allocator->free_lists = list;
+      g_free_list_free (current_allocator->free_list, list);
       G_UNLOCK (current_allocator);
     }
 }
Index: glib/gstring.c
===================================================================
RCS file: /cvs/gnome/glib/glib/gstring.c,v
retrieving revision 1.37
diff -u -p -u -r1.37 gstring.c
--- glib/gstring.c	5 Jun 2003 23:04:20 -0000	1.37
+++ glib/gstring.c	27 Jul 2003 20:45:22 -0000
@@ -52,8 +52,8 @@ struct _GStringChunk
   gsize       default_size;    
 };
 
-G_LOCK_DEFINE_STATIC (string_mem_chunk);
-static GMemChunk *string_mem_chunk = NULL;
+G_LOCK_DEFINE_STATIC (string_lock);
+G_FREE_LIST_DEFINE_STATIC (string_free_list, sizeof (GString), 256);
 
 /* Hash Functions.
  */
@@ -244,14 +244,9 @@ g_string_sized_new (gsize dfl_size)    
 {
   GString *string;
 
-  G_LOCK (string_mem_chunk);
-  if (!string_mem_chunk)
-    string_mem_chunk = g_mem_chunk_new ("string mem chunk",
-					sizeof (GString),
-					1024, G_ALLOC_AND_FREE);
-
-  string = g_chunk_new (GString, string_mem_chunk);
-  G_UNLOCK (string_mem_chunk);
+  G_LOCK (string_lock);
+  string = G_FREE_LIST_ALLOC (string_free_list);
+  G_UNLOCK (string_lock);
 
   string->allocated_len = 0;
   string->len   = 0;
@@ -318,9 +313,9 @@ g_string_free (GString *string,
   else
     segment = string->str;
 
-  G_LOCK (string_mem_chunk);
-  g_mem_chunk_free (string_mem_chunk, string);
-  G_UNLOCK (string_mem_chunk);
+  G_LOCK (string_lock);
+  G_FREE_LIST_FREE (string_free_list, string);
+  G_UNLOCK (string_lock);
 
   return segment;
 }
Index: glib/gtree.c
===================================================================
RCS file: /cvs/gnome/glib/glib/gtree.c,v
retrieving revision 1.36
diff -u -p -u -r1.36 gtree.c
--- glib/gtree.c	25 Jul 2003 21:32:47 -0000	1.36
+++ glib/gtree.c	27 Jul 2003 20:45:23 -0000
@@ -100,9 +100,7 @@ static void       g_tree_node_check     
 
 
 G_LOCK_DEFINE_STATIC (g_tree_global);
-static GMemChunk *node_mem_chunk = NULL;
-static GTreeNode *node_free_list = NULL;
-
+G_FREE_LIST_DEFINE_STATIC (node_free_list, sizeof (GTreeNode), 512);
 
 static GTreeNode*
 g_tree_node_new (gpointer key,
@@ -111,21 +109,7 @@ g_tree_node_new (gpointer key,
   GTreeNode *node;
 
   G_LOCK (g_tree_global);
-  if (node_free_list)
-    {
-      node = node_free_list;
-      node_free_list = node->right;
-    }
-  else
-    {
-      if (!node_mem_chunk)
-	node_mem_chunk = g_mem_chunk_new ("GLib GTreeNode mem chunk",
-					  sizeof (GTreeNode),
-					  1024,
-					  G_ALLOC_ONLY);
-
-      node = g_chunk_new (GTreeNode, node_mem_chunk);
-   }
+  node = G_FREE_LIST_ALLOC (node_free_list);
   G_UNLOCK (g_tree_global);
 
   node->balance = 0;
@@ -161,8 +145,7 @@ g_tree_node_destroy (GTreeNode      *nod
 #endif /* ENABLE_GC_FRIENDLY */
 
       G_LOCK (g_tree_global);
-      node->right = node_free_list;
-      node_free_list = node;
+      G_FREE_LIST_FREE (node_free_list, node);
       G_UNLOCK (g_tree_global);
    }
 }
@@ -722,8 +705,7 @@ g_tree_node_remove (GTree         *tree,
 #endif /* ENABLE_GC_FRIENDLY */
 
       G_LOCK (g_tree_global);
-      garbage->right = node_free_list;
-      node_free_list = garbage;
+      G_FREE_LIST_FREE (node_free_list, garbage);
       G_UNLOCK (g_tree_global);
    }
   else if (cmp < 0)
Index: gobject/gtype.c
===================================================================
RCS file: /cvs/gnome/glib/gobject/gtype.c,v
retrieving revision 1.63
diff -u -p -u -r1.63 gtype.c
--- gobject/gtype.c	8 Jul 2003 20:12:05 -0000	1.63
+++ gobject/gtype.c	27 Jul 2003 20:45:34 -0000
@@ -248,7 +248,7 @@ struct _InstanceData
   guint16            private_size;
   guint16            n_preallocs;
   GInstanceInitFunc  instance_init;
-  GMemChunk        *mem_chunk;
+  GFreeList         *free_list;
 };
 union _TypeData
 {
@@ -936,7 +936,7 @@ type_data_make_W (TypeNode              
       data->instance.n_preallocs = MIN (info->n_preallocs, 1024);
 #endif	/* !DISABLE_MEM_POOLS */
       data->instance.instance_init = info->instance_init;
-      data->instance.mem_chunk = NULL;
+      data->instance.free_list = NULL;
     }
   else if (node->is_classed) /* only classed */
     {
@@ -1404,26 +1404,24 @@ g_type_create_instance (GType type)
   
   if (node->data->instance.n_preallocs)
     {
+      gsize atom_size = total_instance_size;
+      if (node->data->instance.private_size)
+	atom_size = ALIGN_STRUCT (atom_size);
+
       G_WRITE_LOCK (&type_rw_lock);
-      if (!node->data->instance.mem_chunk)
+      if (!node->data->instance.free_list)
 	{
 	  /* If there isn't private data, the compiler will have already
 	   * added the necessary padding, but in the private data case, we
 	   * have to pad ourselves to ensure proper alignment of all the
 	   * atoms in the slab.
 	   */
-	  gsize atom_size = total_instance_size;
-	  if (node->data->instance.private_size)
-	    atom_size = ALIGN_STRUCT (atom_size);
-	  
-	  node->data->instance.mem_chunk = g_mem_chunk_new (NODE_NAME (node),
-							    atom_size,
-							    (atom_size *
-							     node->data->instance.n_preallocs),
-							    G_ALLOC_AND_FREE);
+	  node->data->instance.free_list = g_free_list_new (atom_size,
+							    node->data->instance.n_preallocs);
 	}
       
-      instance = g_chunk_new0 (GTypeInstance, node->data->instance.mem_chunk);
+      instance = g_free_list_alloc (node->data->instance.free_list);
+      memset (instance, 0, atom_size);
       G_WRITE_UNLOCK (&type_rw_lock);
     }
   else
@@ -1478,7 +1476,7 @@ g_type_free_instance (GTypeInstance *ins
   if (node->data->instance.n_preallocs)
     {
       G_WRITE_LOCK (&type_rw_lock);
-      g_chunk_free (instance, node->data->instance.mem_chunk);
+      g_free_list_free (node->data->instance.free_list, instance);
       G_WRITE_UNLOCK (&type_rw_lock);
     }
   else
@@ -1757,10 +1755,10 @@ type_data_last_unref_Wm (GType    type,
       
       node->data->common.ref_count = 0;
       
-      if (node->is_instantiatable && node->data->instance.mem_chunk)
+      if (node->is_instantiatable && node->data->instance.free_list)
 	{
-	  g_mem_chunk_destroy (node->data->instance.mem_chunk);
-	  node->data->instance.mem_chunk = NULL;
+	  g_free_list_destroy (node->data->instance.free_list);
+	  node->data->instance.free_list = NULL;
 	}
       
       tdata = node->data;
