From a2ea02d01ee7b0fe8f2be7f9a34decb17ec8193b Mon Sep 17 00:00:00 2001 From: Ryan Lortie Date: Sun, 18 Sep 2011 20:17:59 -0400 Subject: [PATCH] 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(-) create mode 100644 glib/deprecated/gallocator.c create mode 100644 glib/deprecated/gallocator.h 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. GLib Data Types - @@ -123,7 +122,6 @@ synchronize their operation. - 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
-Memory Chunks -memory_chunks -GMemChunk -G_ALLOC_AND_FREE -G_ALLOC_ONLY - - -g_mem_chunk_new -g_mem_chunk_alloc -g_mem_chunk_alloc0 -g_mem_chunk_free -g_mem_chunk_destroy - - -g_mem_chunk_create -g_chunk_new -g_chunk_new0 -g_chunk_free - - -g_mem_chunk_reset -g_mem_chunk_clean -g_blow_chunks - - -g_mem_chunk_info -g_mem_chunk_print - -
- -
Memory Slices memory_slices g_slice_alloc @@ -2073,10 +2042,6 @@ g_list_find g_list_find_custom g_list_position g_list_index - - -g_list_push_allocator -g_list_pop_allocator
@@ -2121,10 +2086,6 @@ g_slist_find g_slist_find_custom g_slist_position g_slist_index - - -g_slist_push_allocator -g_slist_pop_allocator
@@ -2504,10 +2465,6 @@ g_node_max_height g_node_unlink g_node_destroy - - -g_node_push_allocator -g_node_pop_allocator
@@ -2619,19 +2576,6 @@ GCacheNewFunc
-Memory Allocators -allocators -GAllocator -g_allocator_new -g_allocator_free - - -G_ALLOCATOR_LIST -G_ALLOCATOR_NODE -G_ALLOCATOR_SLIST -
- -
Random Numbers random_numbers 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 +#include + +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 can be included directly." +#endif + +#ifndef __G_ALLOCATOR_H__ +#define __G_ALLOCATOR_H__ + +#include + +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 #endif +#ifndef G_DISABLE_DEPRECATED +#include +#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 - * - * Deprecated:2.10: It does nothing, since #GList has been converted - * to the slice - * allocator - **/ -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 - * - * Deprecated:2.10: It does nothing, since #GList has been converted - * to the slice - * allocator - **/ -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 - * slice allocator 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 slice - * allocator, which has been added in 2.10. All internal uses of - * memory chunks in GLib have been converted to the - * g_slice API. - * - * There are two types of memory chunks, #G_ALLOC_ONLY, and - * #G_ALLOC_AND_FREE. #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. - * #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. - * - * 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(). - * - * - * Using a #GMemChunk - * - * 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 < 10000; i++) - * { - * mem[i] = g_chunk_new (gchar, mem_chunk); - * /* Fill in the atom memory with some junk. */ - * for (j = 0; j < 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 < 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); - * - * - * - * - * Using a #GMemChunk with data structures - * - * 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); - * - * - **/ - -#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 slice - * allocator 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 slice - * allocator 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 slice - * allocator 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 slice - * allocator 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 slice - * allocator 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 slice - * allocator instead - **/ -void g_mem_chunk_info (void) {} - -/** - * g_blow_chunks: - * - * Calls g_mem_chunk_clean() on all #GMemChunk objects. - * - * Deprecated:2.10: Use the slice - * allocator 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 - * sizeof(), and the area size is calculated by - * multiplying the @pre_alloc parameter with the atom size. - * - * Deprecated:2.10: Use the slice - * allocator 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 slice - * allocator 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 slice - * allocator 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 @@ * N-ary Tree. 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 - * - * Deprecated:2.10: It does nothing, since #GNode has been converted to - * the slice - * allocator - **/ -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 - * - * Deprecated:2.10: It does nothing, since #GNode has been converted to - * the slice - * allocator - **/ -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 - * - * Deprecated: 2.10: It does nothing, since #GSList has been converted - * to the slice - * allocator - **/ -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 - * - * Deprecated: 2.10: It does nothing, since #GSList has been converted - * to the slice - * allocator - **/ -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__ */ -- 2.7.4