[glib] Move GAllocator/GMemChunk to separate file



commit a2ea02d01ee7b0fe8f2be7f9a34decb17ec8193b
Author: Ryan Lortie <desrt desrt ca>
Date:   Sun Sep 18 20:17:59 2011 -0400

    Move GAllocator/GMemChunk to separate file
    
    Create a deprecated/ directory that we can start moving ancient chunks
    of code to.  Start with GAllocator, GMemChunk and related APIs.
    
    Also drop all mention of them from the docs.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=659427

 docs/reference/glib/glib-docs.sgml    |    2 -
 docs/reference/glib/glib-sections.txt |   56 ----
 glib/Makefile.am                      |    7 +
 glib/deprecated/gallocator.c          |   99 ++++++++
 glib/deprecated/gallocator.h          |   72 ++++++
 glib/glib.h                           |    4 +
 glib/glist.c                          |   33 ---
 glib/glist.h                          |    5 -
 glib/gmem.c                           |  442 ---------------------------------
 glib/gmem.h                           |   44 ----
 glib/gnode.c                          |   31 ---
 glib/gnode.h                          |    5 -
 glib/gslist.c                         |   32 ---
 glib/gslist.h                         |    5 -
 14 files changed, 182 insertions(+), 655 deletions(-)
---
diff --git a/docs/reference/glib/glib-docs.sgml b/docs/reference/glib/glib-docs.sgml
index 88c91f4..05adf93 100644
--- a/docs/reference/glib/glib-docs.sgml
+++ b/docs/reference/glib/glib-docs.sgml
@@ -104,7 +104,6 @@ synchronize their operation.
   <chapter id="glib-data-types">
     <title>GLib Data Types</title>
       <xi:include href="xml/memory_slices.xml" />
-      <xi:include href="xml/memory_chunks.xml" />
       <xi:include href="xml/linked_lists_double.xml" />
       <xi:include href="xml/linked_lists_single.xml" />
       <xi:include href="xml/queue.xml" />
@@ -123,7 +122,6 @@ synchronize their operation.
       <xi:include href="xml/datasets.xml" />
       <xi:include href="xml/relations.xml" />
       <xi:include href="xml/caches.xml" />
-      <xi:include href="xml/allocators.xml" />
       <xi:include href="xml/gvarianttype.xml"/>
       <xi:include href="xml/gvariant.xml"/>
       <xi:include href="gvariant-varargs.xml"/>
diff --git a/docs/reference/glib/glib-sections.txt b/docs/reference/glib/glib-sections.txt
index 13f3526..dcc8347 100644
--- a/docs/reference/glib/glib-sections.txt
+++ b/docs/reference/glib/glib-sections.txt
@@ -1970,37 +1970,6 @@ g_unix_error_quark
 # Data Structures
 
 <SECTION>
-<TITLE>Memory Chunks</TITLE>
-<FILE>memory_chunks</FILE>
-GMemChunk
-G_ALLOC_AND_FREE
-G_ALLOC_ONLY
-
-<SUBSECTION>
-g_mem_chunk_new
-g_mem_chunk_alloc
-g_mem_chunk_alloc0
-g_mem_chunk_free
-g_mem_chunk_destroy
-
-<SUBSECTION>
-g_mem_chunk_create
-g_chunk_new
-g_chunk_new0
-g_chunk_free
-
-<SUBSECTION>
-g_mem_chunk_reset
-g_mem_chunk_clean
-g_blow_chunks
-
-<SUBSECTION>
-g_mem_chunk_info
-g_mem_chunk_print
-
-</SECTION>
-
-<SECTION>
 <TITLE>Memory Slices</TITLE>
 <FILE>memory_slices</FILE>
 g_slice_alloc
@@ -2073,10 +2042,6 @@ g_list_find
 g_list_find_custom
 g_list_position
 g_list_index
-
-<SUBSECTION>
-g_list_push_allocator
-g_list_pop_allocator
 </SECTION>
 
 <SECTION>
@@ -2121,10 +2086,6 @@ g_slist_find
 g_slist_find_custom
 g_slist_position
 g_slist_index
-
-<SUBSECTION>
-g_slist_push_allocator
-g_slist_pop_allocator
 </SECTION>
 
 <SECTION>
@@ -2504,10 +2465,6 @@ g_node_max_height
 <SUBSECTION>
 g_node_unlink
 g_node_destroy
-
-<SUBSECTION>
-g_node_push_allocator
-g_node_pop_allocator
 </SECTION>
 
 
@@ -2619,19 +2576,6 @@ GCacheNewFunc
 </SECTION>
 
 <SECTION>
-<TITLE>Memory Allocators</TITLE>
-<FILE>allocators</FILE>
-GAllocator
-g_allocator_new
-g_allocator_free
-
-<SUBSECTION Private>
-G_ALLOCATOR_LIST
-G_ALLOCATOR_NODE
-G_ALLOCATOR_SLIST
-</SECTION>
-
-<SECTION>
 <TITLE>Random Numbers</TITLE>
 <FILE>random_numbers</FILE>
 GRand
diff --git a/glib/Makefile.am b/glib/Makefile.am
index 7f0847d..ada9641 100644
--- a/glib/Makefile.am
+++ b/glib/Makefile.am
@@ -111,7 +111,11 @@ install-ms-lib:
 uninstall-ms-lib:
 	$(uninstall_ms_lib_cmd)
 
+deprecated_sources = \
+	deprecated/gallocator.c
+
 libglib_2_0_la_SOURCES = 	\
+	$(deprecated_sources)	\
 	glib_probes.d		\
 	garray.c		\
 	gasyncqueue.c		\
@@ -230,6 +234,9 @@ glibinclude_HEADERS =   \
 	glib-object.h	\
 	glib.h
 
+deprecatedincludedir=$(includedir)/glib-2.0/glib/deprecated
+deprecatedinclude_HEADERS = \
+	deprecated/gallocator.h
 
 glibsubincludedir=$(includedir)/glib-2.0/glib
 glibsubinclude_HEADERS =   \
diff --git a/glib/deprecated/gallocator.c b/glib/deprecated/gallocator.c
new file mode 100644
index 0000000..1831920
--- /dev/null
+++ b/glib/deprecated/gallocator.c
@@ -0,0 +1,99 @@
+/*
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the licence, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#include "gallocator.h"
+
+#include <glib/gmessages.h>
+#include <glib/gslice.h>
+
+struct _GMemChunk {
+  guint alloc_size;           /* the size of an atom */
+};
+
+GMemChunk*
+g_mem_chunk_new (const gchar *name,
+                 gint         atom_size,
+                 gsize        area_size,
+                 gint         type)
+{
+  GMemChunk *mem_chunk;
+
+  g_return_val_if_fail (atom_size > 0, NULL);
+
+  mem_chunk = g_slice_new (GMemChunk);
+  mem_chunk->alloc_size = atom_size;
+
+  return mem_chunk;
+}
+
+void
+g_mem_chunk_destroy (GMemChunk *mem_chunk)
+{
+  g_return_if_fail (mem_chunk != NULL);
+
+  g_slice_free (GMemChunk, mem_chunk);
+}
+
+gpointer
+g_mem_chunk_alloc (GMemChunk *mem_chunk)
+{
+  g_return_val_if_fail (mem_chunk != NULL, NULL);
+
+  return g_slice_alloc (mem_chunk->alloc_size);
+}
+
+gpointer
+g_mem_chunk_alloc0 (GMemChunk *mem_chunk)
+{
+  g_return_val_if_fail (mem_chunk != NULL, NULL);
+
+  return g_slice_alloc0 (mem_chunk->alloc_size);
+}
+
+void
+g_mem_chunk_free (GMemChunk *mem_chunk,
+                  gpointer   mem)
+{
+  g_return_if_fail (mem_chunk != NULL);
+
+  g_slice_free1 (mem_chunk->alloc_size, mem);
+}
+
+GAllocator*
+g_allocator_new (const gchar *name,
+                 guint        n_preallocs)
+{
+  /* some (broken) GAllocator uses depend on non-NULL allocators */
+  return (void *) 1;
+}
+
+void g_allocator_free           (GAllocator *allocator) { }
+
+void g_mem_chunk_clean          (GMemChunk *mem_chunk)  { }
+void g_mem_chunk_reset          (GMemChunk *mem_chunk)  { }
+void g_mem_chunk_print          (GMemChunk *mem_chunk)  { }
+void g_mem_chunk_info           (void)                  { }
+void g_blow_chunks              (void)                  { }
+
+void g_list_push_allocator      (GAllocator *allocator) { }
+void g_list_pop_allocator       (void)                  { }
+
+void g_slist_push_allocator     (GAllocator *allocator) { }
+void g_slist_pop_allocator      (void)                  { }
+
+void g_node_push_allocator      (GAllocator *allocator) { }
+void g_node_pop_allocator       (void)                  { }
diff --git a/glib/deprecated/gallocator.h b/glib/deprecated/gallocator.h
new file mode 100644
index 0000000..7929e48
--- /dev/null
+++ b/glib/deprecated/gallocator.h
@@ -0,0 +1,72 @@
+/*
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the licence, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#if defined(G_DISABLE_SINGLE_INCLUDES) && !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION)
+#error "Only <glib.h> can be included directly."
+#endif
+
+#ifndef __G_ALLOCATOR_H__
+#define __G_ALLOCATOR_H__
+
+#include <glib/gtypes.h>
+
+G_BEGIN_DECLS
+
+typedef struct _GAllocator GAllocator;
+typedef struct _GMemChunk  GMemChunk;
+
+#define G_ALLOC_ONLY                    1
+#define G_ALLOC_AND_FREE                2
+#define G_ALLOCATOR_LIST                1
+#define G_ALLOCATOR_SLIST               2
+#define G_ALLOCATOR_NODE                3
+
+#define g_chunk_new(type, chunk)        ((type *) g_mem_chunk_alloc (chunk))
+#define g_chunk_new0(type, chunk)       ((type *) g_mem_chunk_alloc0 (chunk))
+#define g_chunk_free(mem, mem_chunk)    (g_mem_chunk_free (mem_chunk, mem))
+#define g_mem_chunk_create(type, x, y)  (g_mem_chunk_new (NULL, sizeof (type), 0, 0))
+
+
+GMemChunk *     g_mem_chunk_new         (const gchar  *name,
+                                         gint          atom_size,
+                                         gsize         area_size,
+                                         gint          type);
+void            g_mem_chunk_destroy     (GMemChunk    *mem_chunk);
+gpointer        g_mem_chunk_alloc       (GMemChunk    *mem_chunk);
+gpointer        g_mem_chunk_alloc0      (GMemChunk    *mem_chunk);
+void            g_mem_chunk_free        (GMemChunk    *mem_chunk,
+                                         gpointer      mem);
+void            g_mem_chunk_clean       (GMemChunk    *mem_chunk);
+void            g_mem_chunk_reset       (GMemChunk    *mem_chunk);
+void            g_mem_chunk_print       (GMemChunk    *mem_chunk);
+void            g_mem_chunk_info        (void);
+void            g_blow_chunks           (void);
+
+
+GAllocator *    g_allocator_new         (const gchar  *name,
+                                         guint         n_preallocs);
+void            g_allocator_free        (GAllocator   *allocator);
+void            g_list_push_allocator   (GAllocator   *allocator);
+void            g_list_pop_allocator    (void);
+void            g_slist_push_allocator  (GAllocator   *allocator);
+void            g_slist_pop_allocator   (void);
+void            g_node_push_allocator   (GAllocator   *allocator);
+void            g_node_pop_allocator    (void);
+
+G_END_DECLS
+
+#endif /* __G_ALLOCATOR_H__ */
diff --git a/glib/glib.h b/glib/glib.h
index ebbbebd..95cbe75 100644
--- a/glib/glib.h
+++ b/glib/glib.h
@@ -95,6 +95,10 @@
 #include <glib/gwin32.h>
 #endif
 
+#ifndef G_DISABLE_DEPRECATED
+#include <glib/deprecated/gallocator.h>
+#endif
+
 #undef __GLIB_H_INSIDE__
 
 #endif /* __G_LIB_H__ */
diff --git a/glib/glist.c b/glib/glist.c
index 1e3dd86..33db0b7 100644
--- a/glib/glist.c
+++ b/glib/glist.c
@@ -112,39 +112,6 @@
  * A convenience macro to get the next element in a #GList.
  **/
 
-
-
-/**
- * g_list_push_allocator:
- * @allocator: the #GAllocator to use when allocating #GList elements.
- *
- * Sets the allocator to use to allocate #GList elements. Use
- * g_list_pop_allocator() to restore the previous allocator.
- *
- * Note that this function is not available if GLib has been compiled
- * with <option>--disable-mem-pools</option>
- *
- * Deprecated:2.10: It does nothing, since #GList has been converted
- *                  to the <link linkend="glib-Memory-Slices">slice
- *                  allocator</link>
- **/
-void g_list_push_allocator (gpointer dummy) { /* present for binary compat only */ }
-
-/**
- * g_list_pop_allocator:
- *
- * Restores the previous #GAllocator, used when allocating #GList
- * elements.
- *
- * Note that this function is not available if GLib has been compiled
- * with <option>--disable-mem-pools</option>
- *
- * Deprecated:2.10: It does nothing, since #GList has been converted
- *                  to the <link linkend="glib-Memory-Slices">slice
- *                  allocator</link>
- **/
-void g_list_pop_allocator  (void)           { /* present for binary compat only */ }
-
 #define _g_list_alloc()         g_slice_new (GList)
 #define _g_list_alloc0()        g_slice_new0 (GList)
 #define _g_list_free1(list)     g_slice_free (GList, list)
diff --git a/glib/glist.h b/glib/glist.h
index 275005c..52eee10 100644
--- a/glib/glist.h
+++ b/glib/glist.h
@@ -112,11 +112,6 @@ gpointer g_list_nth_data                (GList            *list,
 #define g_list_previous(list)	        ((list) ? (((GList *)(list))->prev) : NULL)
 #define g_list_next(list)	        ((list) ? (((GList *)(list))->next) : NULL)
 
-#ifndef G_DISABLE_DEPRECATED
-void     g_list_push_allocator          (gpointer          allocator);
-void     g_list_pop_allocator           (void);
-#endif
-
 G_END_DECLS
 
 #endif /* __G_LIST_H__ */
diff --git a/glib/gmem.c b/glib/gmem.c
index a657f73..a79684f 100644
--- a/glib/gmem.c
+++ b/glib/gmem.c
@@ -909,448 +909,6 @@ GMemVTable *glib_mem_profiler_table = &profiler_table;
 
 #endif	/* !G_DISABLE_CHECKS */
 
-/* --- MemChunks --- */
-/**
- * SECTION:allocators
- * @title: Memory Allocators
- * @short_description: deprecated way to allocate chunks of memory for
- *                     GList, GSList and GNode
- *
- * Prior to 2.10, #GAllocator was used as an efficient way to allocate
- * small pieces of memory for use with the #GList, #GSList and #GNode
- * data structures. Since 2.10, it has been completely replaced by the
- * <link linkend="glib-Memory-Slices">slice allocator</link> and
- * deprecated.
- **/
-
-/**
- * SECTION:memory_chunks
- * @title: Memory Chunks
- * @short_description: deprecated way to allocate groups of equal-sized
- *                     chunks of memory
- *
- * Memory chunks provide an space-efficient way to allocate equal-sized
- * pieces of memory, called atoms. However, due to the administrative
- * overhead (in particular for #G_ALLOC_AND_FREE, and when used from
- * multiple threads), they are in practise often slower than direct use
- * of g_malloc(). Therefore, memory chunks have been deprecated in
- * favor of the <link linkend="glib-Memory-Slices">slice
- * allocator</link>, which has been added in 2.10. All internal uses of
- * memory chunks in GLib have been converted to the
- * <literal>g_slice</literal> API.
- *
- * There are two types of memory chunks, #G_ALLOC_ONLY, and
- * #G_ALLOC_AND_FREE. <itemizedlist> <listitem><para> #G_ALLOC_ONLY
- * chunks only allow allocation of atoms. The atoms can never be freed
- * individually. The memory chunk can only be free in its entirety.
- * </para></listitem> <listitem><para> #G_ALLOC_AND_FREE chunks do
- * allow atoms to be freed individually. The disadvantage of this is
- * that the memory chunk has to keep track of which atoms have been
- * freed. This results in more memory being used and a slight
- * degradation in performance. </para></listitem> </itemizedlist>
- *
- * To create a memory chunk use g_mem_chunk_new() or the convenience
- * macro g_mem_chunk_create().
- *
- * To allocate a new atom use g_mem_chunk_alloc(),
- * g_mem_chunk_alloc0(), or the convenience macros g_chunk_new() or
- * g_chunk_new0().
- *
- * To free an atom use g_mem_chunk_free(), or the convenience macro
- * g_chunk_free(). (Atoms can only be freed if the memory chunk is
- * created with the type set to #G_ALLOC_AND_FREE.)
- *
- * To free any blocks of memory which are no longer being used, use
- * g_mem_chunk_clean(). To clean all memory chunks, use g_blow_chunks().
- *
- * To reset the memory chunk, freeing all of the atoms, use
- * g_mem_chunk_reset().
- *
- * To destroy a memory chunk, use g_mem_chunk_destroy().
- *
- * To help debug memory chunks, use g_mem_chunk_info() and
- * g_mem_chunk_print().
- *
- * <example>
- *  <title>Using a #GMemChunk</title>
- *  <programlisting>
- *   GMemChunk *mem_chunk;
- *   gchar *mem[10000];
- *   gint i;
- *
- *   /<!-- -->* Create a GMemChunk with atoms 50 bytes long, and memory
- *      blocks holding 100 bytes. Note that this means that only 2 atoms
- *      fit into each memory block and so isn't very efficient. *<!-- -->/
- *   mem_chunk = g_mem_chunk_new ("test mem chunk", 50, 100, G_ALLOC_AND_FREE);
- *   /<!-- -->* Now allocate 10000 atoms. *<!-- -->/
- *   for (i = 0; i &lt; 10000; i++)
- *     {
- *       mem[i] = g_chunk_new (gchar, mem_chunk);
- *       /<!-- -->* Fill in the atom memory with some junk. *<!-- -->/
- *       for (j = 0; j &lt; 50; j++)
- *         mem[i][j] = i * j;
- *     }
- *   /<!-- -->* Now free all of the atoms. Note that since we are going to
- *      destroy the GMemChunk, this wouldn't normally be used. *<!-- -->/
- *   for (i = 0; i &lt; 10000; i++)
- *     {
- *       g_mem_chunk_free (mem_chunk, mem[i]);
- *     }
- *   /<!-- -->* We are finished with the GMemChunk, so we destroy it. *<!-- -->/
- *   g_mem_chunk_destroy (mem_chunk);
- *  </programlisting>
- * </example>
- *
- * <example>
- *  <title>Using a #GMemChunk with data structures</title>
- *  <programlisting>
- *    GMemChunk *array_mem_chunk;
- *    GRealArray *array;
- *    /<!-- -->* Create a GMemChunk to hold GRealArray structures, using
- *       the g_mem_chunk_create(<!-- -->) convenience macro. We want 1024 atoms in each
- *       memory block, and we want to be able to free individual atoms. *<!-- -->/
- *    array_mem_chunk = g_mem_chunk_create (GRealArray, 1024, G_ALLOC_AND_FREE);
- *    /<!-- -->* Allocate one atom, using the g_chunk_new(<!-- -->) convenience macro. *<!-- -->/
- *    array = g_chunk_new (GRealArray, array_mem_chunk);
- *    /<!-- -->* We can now use array just like a normal pointer to a structure. *<!-- -->/
- *    array->data            = NULL;
- *    array->len             = 0;
- *    array->alloc           = 0;
- *    array->zero_terminated = (zero_terminated ? 1 : 0);
- *    array->clear           = (clear ? 1 : 0);
- *    array->elt_size        = elt_size;
- *    /<!-- -->* We can free the element, so it can be reused. *<!-- -->/
- *    g_chunk_free (array, array_mem_chunk);
- *    /<!-- -->* We destroy the GMemChunk when we are finished with it. *<!-- -->/
- *    g_mem_chunk_destroy (array_mem_chunk);
- *  </programlisting>
- * </example>
- **/
-
-#ifndef G_ALLOC_AND_FREE
-
-/**
- * GAllocator:
- *
- * The #GAllocator struct contains private data. and should only be
- * accessed using the following functions.
- **/
-typedef struct _GAllocator GAllocator;
-
-/**
- * GMemChunk:
- *
- * The #GMemChunk struct is an opaque data structure representing a
- * memory chunk. It should be accessed only through the use of the
- * following functions.
- **/
-typedef struct _GMemChunk  GMemChunk;
-
-/**
- * G_ALLOC_ONLY:
- *
- * Specifies the type of a #GMemChunk. Used in g_mem_chunk_new() and
- * g_mem_chunk_create() to specify that atoms will never be freed
- * individually.
- **/
-#define G_ALLOC_ONLY	  1
-
-/**
- * G_ALLOC_AND_FREE:
- *
- * Specifies the type of a #GMemChunk. Used in g_mem_chunk_new() and
- * g_mem_chunk_create() to specify that atoms will be freed
- * individually.
- **/
-#define G_ALLOC_AND_FREE  2
-#endif
-
-struct _GMemChunk {
-  guint alloc_size;           /* the size of an atom */
-};
-
-/**
- * g_mem_chunk_new:
- * @name: a string to identify the #GMemChunk. It is not copied so it
- *        should be valid for the lifetime of the #GMemChunk. It is
- *        only used in g_mem_chunk_print(), which is used for debugging.
- * @atom_size: the size, in bytes, of each element in the #GMemChunk.
- * @area_size: the size, in bytes, of each block of memory allocated to
- *             contain the atoms.
- * @type: the type of the #GMemChunk.  #G_ALLOC_AND_FREE is used if the
- *        atoms will be freed individually.  #G_ALLOC_ONLY should be
- *        used if atoms will never be freed individually.
- *        #G_ALLOC_ONLY is quicker, since it does not need to track
- *        free atoms, but it obviously wastes memory if you no longer
- *        need many of the atoms.
- * @Returns: the new #GMemChunk.
- *
- * Creates a new #GMemChunk.
- *
- * Deprecated:2.10: Use the <link linkend="glib-Memory-Slices">slice
- *                  allocator</link> instead
- **/
-GMemChunk*
-g_mem_chunk_new (const gchar  *name,
-		 gint          atom_size,
-		 gsize         area_size,
-		 gint          type)
-{
-  GMemChunk *mem_chunk;
-  g_return_val_if_fail (atom_size > 0, NULL);
-
-  mem_chunk = g_slice_new (GMemChunk);
-  mem_chunk->alloc_size = atom_size;
-  return mem_chunk;
-}
-
-/**
- * g_mem_chunk_destroy:
- * @mem_chunk: a #GMemChunk.
- *
- * Frees all of the memory allocated for a #GMemChunk.
- *
- * Deprecated:2.10: Use the <link linkend="glib-Memory-Slices">slice
- *                  allocator</link> instead
- **/
-void
-g_mem_chunk_destroy (GMemChunk *mem_chunk)
-{
-  g_return_if_fail (mem_chunk != NULL);
-  
-  g_slice_free (GMemChunk, mem_chunk);
-}
-
-/**
- * g_mem_chunk_alloc:
- * @mem_chunk: a #GMemChunk.
- * @Returns: a pointer to the allocated atom.
- *
- * Allocates an atom of memory from a #GMemChunk.
- *
- * Deprecated:2.10: Use g_slice_alloc() instead
- **/
-gpointer
-g_mem_chunk_alloc (GMemChunk *mem_chunk)
-{
-  g_return_val_if_fail (mem_chunk != NULL, NULL);
-  
-  return g_slice_alloc (mem_chunk->alloc_size);
-}
-
-/**
- * g_mem_chunk_alloc0:
- * @mem_chunk: a #GMemChunk.
- * @Returns: a pointer to the allocated atom.
- *
- * Allocates an atom of memory from a #GMemChunk, setting the memory to
- * 0.
- *
- * Deprecated:2.10: Use g_slice_alloc0() instead
- **/
-gpointer
-g_mem_chunk_alloc0 (GMemChunk *mem_chunk)
-{
-  g_return_val_if_fail (mem_chunk != NULL, NULL);
-  
-  return g_slice_alloc0 (mem_chunk->alloc_size);
-}
-
-/**
- * g_mem_chunk_free:
- * @mem_chunk: a #GMemChunk.
- * @mem: a pointer to the atom to free.
- *
- * Frees an atom in a #GMemChunk. This should only be called if the
- * #GMemChunk was created with #G_ALLOC_AND_FREE. Otherwise it will
- * simply return.
- *
- * Deprecated:2.10: Use g_slice_free1() instead
- **/
-void
-g_mem_chunk_free (GMemChunk *mem_chunk,
-		  gpointer   mem)
-{
-  g_return_if_fail (mem_chunk != NULL);
-  
-  g_slice_free1 (mem_chunk->alloc_size, mem);
-}
-
-/**
- * g_mem_chunk_clean:
- * @mem_chunk: a #GMemChunk.
- *
- * Frees any blocks in a #GMemChunk which are no longer being used.
- *
- * Deprecated:2.10: Use the <link linkend="glib-Memory-Slices">slice
- *                  allocator</link> instead
- **/
-void	g_mem_chunk_clean	(GMemChunk *mem_chunk)	{}
-
-/**
- * g_mem_chunk_reset:
- * @mem_chunk: a #GMemChunk.
- *
- * Resets a GMemChunk to its initial state. It frees all of the
- * currently allocated blocks of memory.
- *
- * Deprecated:2.10: Use the <link linkend="glib-Memory-Slices">slice
- *                  allocator</link> instead
- **/
-void	g_mem_chunk_reset	(GMemChunk *mem_chunk)	{}
-
-
-/**
- * g_mem_chunk_print:
- * @mem_chunk: a #GMemChunk.
- *
- * Outputs debugging information for a #GMemChunk. It outputs the name
- * of the #GMemChunk (set with g_mem_chunk_new()), the number of bytes
- * used, and the number of blocks of memory allocated.
- *
- * Deprecated:2.10: Use the <link linkend="glib-Memory-Slices">slice
- *                  allocator</link> instead
- **/
-void	g_mem_chunk_print	(GMemChunk *mem_chunk)	{}
-
-
-/**
- * g_mem_chunk_info:
- *
- * Outputs debugging information for all #GMemChunk objects currently
- * in use. It outputs the number of #GMemChunk objects currently
- * allocated, and calls g_mem_chunk_print() to output information on
- * each one.
- *
- * Deprecated:2.10: Use the <link linkend="glib-Memory-Slices">slice
- *                  allocator</link> instead
- **/
-void	g_mem_chunk_info	(void)			{}
-
-/**
- * g_blow_chunks:
- *
- * Calls g_mem_chunk_clean() on all #GMemChunk objects.
- *
- * Deprecated:2.10: Use the <link linkend="glib-Memory-Slices">slice
- *                  allocator</link> instead
- **/
-void	g_blow_chunks		(void)			{}
-
-/**
- * g_chunk_new0:
- * @type: the type of the #GMemChunk atoms, typically a structure name.
- * @chunk: a #GMemChunk.
- * @Returns: a pointer to the allocated atom, cast to a pointer to
- *           @type.
- *
- * A convenience macro to allocate an atom of memory from a #GMemChunk.
- * It calls g_mem_chunk_alloc0() and casts the returned atom to a
- * pointer to the given type, avoiding a type cast in the source code.
- *
- * Deprecated:2.10: Use g_slice_new0() instead
- **/
-
-/**
- * g_chunk_free:
- * @mem: a pointer to the atom to be freed.
- * @mem_chunk: a #GMemChunk.
- *
- * A convenience macro to free an atom of memory from a #GMemChunk. It
- * simply switches the arguments and calls g_mem_chunk_free() It is
- * included simply to complement the other convenience macros,
- * g_chunk_new() and g_chunk_new0().
- *
- * Deprecated:2.10: Use g_slice_free() instead
- **/
-
-/**
- * g_chunk_new:
- * @type: the type of the #GMemChunk atoms, typically a structure name.
- * @chunk: a #GMemChunk.
- * @Returns: a pointer to the allocated atom, cast to a pointer to
- *           @type.
- *
- * A convenience macro to allocate an atom of memory from a #GMemChunk.
- * It calls g_mem_chunk_alloc() and casts the returned atom to a
- * pointer to the given type, avoiding a type cast in the source code.
- *
- * Deprecated:2.10: Use g_slice_new() instead
- **/
-
-/**
- * g_mem_chunk_create:
- * @type: the type of the atoms, typically a structure name.
- * @pre_alloc: the number of atoms to store in each block of memory.
- * @alloc_type: the type of the #GMemChunk.  #G_ALLOC_AND_FREE is used
- *              if the atoms will be freed individually.  #G_ALLOC_ONLY
- *              should be used if atoms will never be freed
- *              individually.  #G_ALLOC_ONLY is quicker, since it does
- *              not need to track free atoms, but it obviously wastes
- *              memory if you no longer need many of the atoms.
- * @Returns: the new #GMemChunk.
- *
- * A convenience macro for creating a new #GMemChunk. It calls
- * g_mem_chunk_new(), using the given type to create the #GMemChunk
- * name. The atom size is determined using
- * <function>sizeof()</function>, and the area size is calculated by
- * multiplying the @pre_alloc parameter with the atom size.
- *
- * Deprecated:2.10: Use the <link linkend="glib-Memory-Slices">slice
- *                  allocator</link> instead
- **/
-
-
-/**
- * g_allocator_new:
- * @name: the name of the #GAllocator. This name is used to set the
- *        name of the #GMemChunk used by the #GAllocator, and is only
- *        used for debugging.
- * @n_preallocs: the number of elements in each block of memory
- *               allocated.  Larger blocks mean less calls to
- *               g_malloc(), but some memory may be wasted.  (GLib uses
- *               128 elements per block by default.) The value must be
- *               between 1 and 65535.
- * @Returns: a new #GAllocator.
- *
- * Creates a new #GAllocator.
- *
- * Deprecated:2.10: Use the <link linkend="glib-Memory-Slices">slice
- *                  allocator</link> instead
- **/
-GAllocator*
-g_allocator_new (const gchar *name,
-		 guint        n_preallocs)
-{
-  static struct _GAllocator {
-    gchar      *name;
-    guint16     n_preallocs;
-    guint       is_unused : 1;
-    guint       type : 4;
-    GAllocator *last;
-    GMemChunk  *mem_chunk;
-    gpointer    free_list;
-  } dummy = {
-    "GAllocator is deprecated", 1, TRUE, 0, NULL, NULL, NULL,
-  };
-  /* some (broken) GAllocator uses depend on non-NULL allocators */
-  return (void*) &dummy;
-}
-
-/**
- * g_allocator_free:
- * @allocator: a #GAllocator.
- *
- * Frees all of the memory allocated by the #GAllocator.
- *
- * Deprecated:2.10: Use the <link linkend="glib-Memory-Slices">slice
- *                  allocator</link> instead
- **/
-void
-g_allocator_free (GAllocator *allocator)
-{
-}
-
 #ifdef ENABLE_GC_FRIENDLY_DEFAULT
 gboolean g_mem_gc_friendly = TRUE;
 #else
diff --git a/glib/gmem.h b/glib/gmem.h
index a8ff4ac..8f57d34 100644
--- a/glib/gmem.h
+++ b/glib/gmem.h
@@ -260,50 +260,6 @@ GLIB_VAR gboolean g_mem_gc_friendly;
 GLIB_VAR GMemVTable	*glib_mem_profiler_table;
 void	g_mem_profile	(void);
 
-
-/* deprecated memchunks and allocators */
-#if !defined (G_DISABLE_DEPRECATED) || defined (GTK_COMPILATION) || defined (GDK_COMPILATION)
-typedef struct _GAllocator GAllocator;
-typedef struct _GMemChunk  GMemChunk;
-#define g_mem_chunk_create(type, pre_alloc, alloc_type)	( \
-  g_mem_chunk_new (#type " mem chunks (" #pre_alloc ")", \
-		   sizeof (type), \
-		   sizeof (type) * (pre_alloc), \
-		   (alloc_type)) \
-)
-#define g_chunk_new(type, chunk)	( \
-  (type *) g_mem_chunk_alloc (chunk) \
-)
-#define g_chunk_new0(type, chunk)	( \
-  (type *) g_mem_chunk_alloc0 (chunk) \
-)
-#define g_chunk_free(mem, mem_chunk)	G_STMT_START { \
-  g_mem_chunk_free ((mem_chunk), (mem)); \
-} G_STMT_END
-#define G_ALLOC_ONLY	  1
-#define G_ALLOC_AND_FREE  2
-GMemChunk* g_mem_chunk_new     (const gchar *name,
-				gint         atom_size,
-				gsize        area_size,
-				gint         type);
-void       g_mem_chunk_destroy (GMemChunk   *mem_chunk);
-gpointer   g_mem_chunk_alloc   (GMemChunk   *mem_chunk);
-gpointer   g_mem_chunk_alloc0  (GMemChunk   *mem_chunk);
-void       g_mem_chunk_free    (GMemChunk   *mem_chunk,
-				gpointer     mem);
-void       g_mem_chunk_clean   (GMemChunk   *mem_chunk);
-void       g_mem_chunk_reset   (GMemChunk   *mem_chunk);
-void       g_mem_chunk_print   (GMemChunk   *mem_chunk);
-void       g_mem_chunk_info    (void);
-void	   g_blow_chunks       (void);
-GAllocator*g_allocator_new     (const gchar  *name,
-				guint         n_preallocs);
-void       g_allocator_free    (GAllocator   *allocator);
-#define	G_ALLOCATOR_LIST       (1)
-#define	G_ALLOCATOR_SLIST      (2)
-#define	G_ALLOCATOR_NODE       (3)
-#endif /* G_DISABLE_DEPRECATED */
-
 G_END_DECLS
 
 #endif /* __G_MEM_H__ */
diff --git a/glib/gnode.c b/glib/gnode.c
index 54bec7a..b9cea62 100644
--- a/glib/gnode.c
+++ b/glib/gnode.c
@@ -89,37 +89,6 @@
  * <link linkend="glib-N-ary-Trees">N-ary Tree</link>. fields
  **/
 
-/**
- * g_node_push_allocator:
- * @dummy: the #GAllocator to use when allocating #GNode elements.
- *
- * Sets the allocator to use to allocate #GNode elements. Use
- * g_node_pop_allocator() to restore the previous allocator.
- *
- * Note that this function is not available if GLib has been compiled
- * with <option>--disable-mem-pools</option>
- *
- * Deprecated:2.10: It does nothing, since #GNode has been converted to
- *                  the <link linkend="glib-Memory-Slices">slice
- *                  allocator</link>
- **/
-void g_node_push_allocator (gpointer dummy) { /* present for binary compat only */ }
-
-/**
- * g_node_pop_allocator:
- *
- * Restores the previous #GAllocator, used when allocating #GNode
- * elements.
- *
- * Note that this function is not available if GLib has been compiled
- * with <option>--disable-mem-pools</option>
- *
- * Deprecated:2.10: It does nothing, since #GNode has been converted to
- *                  the <link linkend="glib-Memory-Slices">slice
- *                  allocator</link>
- **/
-void g_node_pop_allocator  (void)           { /* present for binary compat only */ }
-
 #define g_node_alloc0()         g_slice_new0 (GNode)
 #define g_node_free(node)       g_slice_free (GNode, node)
 
diff --git a/glib/gnode.h b/glib/gnode.h
index 205d47c..6ad6e54 100644
--- a/glib/gnode.h
+++ b/glib/gnode.h
@@ -280,11 +280,6 @@ GNode*	 g_node_last_sibling	 (GNode		  *node);
 #define	 g_node_first_child(node)	((node) ? \
 					 ((GNode*) (node))->children : NULL)
 
-#ifndef G_DISABLE_DEPRECATED
-void     g_node_push_allocator  (gpointer          dummy);
-void     g_node_pop_allocator   (void);
-#endif
-
 G_END_DECLS
 
 #endif /* __G_NODE_H__ */
diff --git a/glib/gslist.c b/glib/gslist.c
index 1de9c57..6f86675 100644
--- a/glib/gslist.c
+++ b/glib/gslist.c
@@ -103,38 +103,6 @@
  * A convenience macro to get the next element in a #GSList.
  **/
 
-
-/**
- * g_slist_push_allocator:
- * @dummy: the #GAllocator to use when allocating #GSList elements.
- *
- * Sets the allocator to use to allocate #GSList elements. Use
- * g_slist_pop_allocator() to restore the previous allocator.
- *
- * Note that this function is not available if GLib has been compiled
- * with <option>--disable-mem-pools</option>
- *
- * Deprecated: 2.10: It does nothing, since #GSList has been converted
- *                   to the <link linkend="glib-Memory-Slices">slice
- *                   allocator</link>
- **/
-void g_slist_push_allocator (gpointer dummy) { /* present for binary compat only */ }
-
-/**
- * g_slist_pop_allocator:
- *
- * Restores the previous #GAllocator, used when allocating #GSList
- * elements.
- *
- * Note that this function is not available if GLib has been compiled
- * with <option>--disable-mem-pools</option>
- *
- * Deprecated: 2.10: It does nothing, since #GSList has been converted
- *                   to the <link linkend="glib-Memory-Slices">slice
- *                   allocator</link>
- **/
-void g_slist_pop_allocator  (void)           { /* present for binary compat only */ }
-
 #define _g_slist_alloc0()       g_slice_new0 (GSList)
 #define _g_slist_alloc()        g_slice_new (GSList)
 #define _g_slist_free1(slist)   g_slice_free (GSList, slist)
diff --git a/glib/gslist.h b/glib/gslist.h
index 3731ba9..35a39a3 100644
--- a/glib/gslist.h
+++ b/glib/gslist.h
@@ -106,11 +106,6 @@ gpointer g_slist_nth_data                (GSList           *list,
 
 #define  g_slist_next(slist)	         ((slist) ? (((GSList *)(slist))->next) : NULL)
 
-#ifndef G_DISABLE_DEPRECATED
-void     g_slist_push_allocator          (gpointer	   dummy);
-void     g_slist_pop_allocator           (void);
-#endif
-
 G_END_DECLS
 
 #endif /* __G_SLIST_H__ */



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]