[kdbus] KDBUS_ITEM_PAYLOAD_OFF items are (once again) relative to msg header
[platform/upstream/glib.git] / glib / deprecated / gallocator.c
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 of the licence, 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 #define GLIB_DISABLE_DEPRECATION_WARNINGS
20
21 #include "gallocator.h"
22
23 #include <glib/gmessages.h>
24 #include <glib/gslice.h>
25
26 struct _GMemChunk {
27   guint alloc_size;           /* the size of an atom */
28 };
29
30 GMemChunk*
31 g_mem_chunk_new (const gchar *name,
32                  gint         atom_size,
33                  gsize        area_size,
34                  gint         type)
35 {
36   GMemChunk *mem_chunk;
37
38   g_return_val_if_fail (atom_size > 0, NULL);
39
40   mem_chunk = g_slice_new (GMemChunk);
41   mem_chunk->alloc_size = atom_size;
42
43   return mem_chunk;
44 }
45
46 void
47 g_mem_chunk_destroy (GMemChunk *mem_chunk)
48 {
49   g_return_if_fail (mem_chunk != NULL);
50
51   g_slice_free (GMemChunk, mem_chunk);
52 }
53
54 gpointer
55 g_mem_chunk_alloc (GMemChunk *mem_chunk)
56 {
57   g_return_val_if_fail (mem_chunk != NULL, NULL);
58
59   return g_slice_alloc (mem_chunk->alloc_size);
60 }
61
62 gpointer
63 g_mem_chunk_alloc0 (GMemChunk *mem_chunk)
64 {
65   g_return_val_if_fail (mem_chunk != NULL, NULL);
66
67   return g_slice_alloc0 (mem_chunk->alloc_size);
68 }
69
70 void
71 g_mem_chunk_free (GMemChunk *mem_chunk,
72                   gpointer   mem)
73 {
74   g_return_if_fail (mem_chunk != NULL);
75
76   g_slice_free1 (mem_chunk->alloc_size, mem);
77 }
78
79 GAllocator*
80 g_allocator_new (const gchar *name,
81                  guint        n_preallocs)
82 {
83   /* some (broken) GAllocator uses depend on non-NULL allocators */
84   return (void *) 1;
85 }
86
87 void g_allocator_free           (GAllocator *allocator) { }
88
89 void g_mem_chunk_clean          (GMemChunk *mem_chunk)  { }
90 void g_mem_chunk_reset          (GMemChunk *mem_chunk)  { }
91 void g_mem_chunk_print          (GMemChunk *mem_chunk)  { }
92 void g_mem_chunk_info           (void)                  { }
93 void g_blow_chunks              (void)                  { }
94
95 void g_list_push_allocator      (GAllocator *allocator) { }
96 void g_list_pop_allocator       (void)                  { }
97
98 void g_slist_push_allocator     (GAllocator *allocator) { }
99 void g_slist_pop_allocator      (void)                  { }
100
101 void g_node_push_allocator      (GAllocator *allocator) { }
102 void g_node_pop_allocator       (void)                  { }