1/*
2 * This library is free software; you can redistribute it and/or
3 * modify it under the terms of the GNU Lesser General Public
4 * License as published by the Free Software Foundation; either
5 * version 2.1 of the License, or (at your option) any later version.
6 *
7 * This library is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
10 * Lesser General Public License for more details.
11 *
12 * You should have received a copy of the GNU Lesser General Public
13 * License along with this library; if not, see <http://www.gnu.org/licenses/>.
14 */
15
16#include "config.h"
17
18/* we know we are deprecated here, no need for warnings */
19#ifndef GLIB_DISABLE_DEPRECATION_WARNINGS
20#define GLIB_DISABLE_DEPRECATION_WARNINGS
21#endif
22
23#include "gallocator.h"
24
25#include <glib/gmessages.h>
26#include <glib/gslice.h>
27
28struct _GMemChunk {
29 guint alloc_size; /* the size of an atom */
30};
31
32GMemChunk*
33g_mem_chunk_new (const gchar *name,
34 gint atom_size,
35 gsize area_size,
36 gint type)
37{
38 GMemChunk *mem_chunk;
39
40 g_return_val_if_fail (atom_size > 0, NULL);
41
42 mem_chunk = g_slice_new (GMemChunk);
43 mem_chunk->alloc_size = atom_size;
44
45 return mem_chunk;
46}
47
48void
49g_mem_chunk_destroy (GMemChunk *mem_chunk)
50{
51 g_return_if_fail (mem_chunk != NULL);
52
53 g_slice_free (GMemChunk, mem_chunk);
54}
55
56gpointer
57g_mem_chunk_alloc (GMemChunk *mem_chunk)
58{
59 g_return_val_if_fail (mem_chunk != NULL, NULL);
60
61 return g_slice_alloc (block_size: mem_chunk->alloc_size);
62}
63
64gpointer
65g_mem_chunk_alloc0 (GMemChunk *mem_chunk)
66{
67 g_return_val_if_fail (mem_chunk != NULL, NULL);
68
69 return g_slice_alloc0 (block_size: mem_chunk->alloc_size);
70}
71
72void
73g_mem_chunk_free (GMemChunk *mem_chunk,
74 gpointer mem)
75{
76 g_return_if_fail (mem_chunk != NULL);
77
78 g_slice_free1 (block_size: mem_chunk->alloc_size, mem_block: mem);
79}
80
81GAllocator*
82g_allocator_new (const gchar *name,
83 guint n_preallocs)
84{
85 /* some (broken) GAllocator uses depend on non-NULL allocators */
86 return (void *) 1;
87}
88
89void g_allocator_free (GAllocator *allocator) { }
90
91void g_mem_chunk_clean (GMemChunk *mem_chunk) { }
92void g_mem_chunk_reset (GMemChunk *mem_chunk) { }
93void g_mem_chunk_print (GMemChunk *mem_chunk) { }
94void g_mem_chunk_info (void) { }
95void g_blow_chunks (void) { }
96
97void g_list_push_allocator (GAllocator *allocator) { }
98void g_list_pop_allocator (void) { }
99
100void g_slist_push_allocator (GAllocator *allocator) { }
101void g_slist_pop_allocator (void) { }
102
103void g_node_push_allocator (GAllocator *allocator) { }
104void g_node_pop_allocator (void) { }
105

source code of gtk/subprojects/glib/glib/deprecated/gallocator.c