Move GAllocator/GMemChunk to separate file
[platform/upstream/glib.git] / glib / deprecated / gallocator.h
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, write to the
14  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
15  * Boston, MA 02111-1307, USA.
16  */
17
18 #if defined(G_DISABLE_SINGLE_INCLUDES) && !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION)
19 #error "Only <glib.h> can be included directly."
20 #endif
21
22 #ifndef __G_ALLOCATOR_H__
23 #define __G_ALLOCATOR_H__
24
25 #include <glib/gtypes.h>
26
27 G_BEGIN_DECLS
28
29 typedef struct _GAllocator GAllocator;
30 typedef struct _GMemChunk  GMemChunk;
31
32 #define G_ALLOC_ONLY                    1
33 #define G_ALLOC_AND_FREE                2
34 #define G_ALLOCATOR_LIST                1
35 #define G_ALLOCATOR_SLIST               2
36 #define G_ALLOCATOR_NODE                3
37
38 #define g_chunk_new(type, chunk)        ((type *) g_mem_chunk_alloc (chunk))
39 #define g_chunk_new0(type, chunk)       ((type *) g_mem_chunk_alloc0 (chunk))
40 #define g_chunk_free(mem, mem_chunk)    (g_mem_chunk_free (mem_chunk, mem))
41 #define g_mem_chunk_create(type, x, y)  (g_mem_chunk_new (NULL, sizeof (type), 0, 0))
42
43
44 GMemChunk *     g_mem_chunk_new         (const gchar  *name,
45                                          gint          atom_size,
46                                          gsize         area_size,
47                                          gint          type);
48 void            g_mem_chunk_destroy     (GMemChunk    *mem_chunk);
49 gpointer        g_mem_chunk_alloc       (GMemChunk    *mem_chunk);
50 gpointer        g_mem_chunk_alloc0      (GMemChunk    *mem_chunk);
51 void            g_mem_chunk_free        (GMemChunk    *mem_chunk,
52                                          gpointer      mem);
53 void            g_mem_chunk_clean       (GMemChunk    *mem_chunk);
54 void            g_mem_chunk_reset       (GMemChunk    *mem_chunk);
55 void            g_mem_chunk_print       (GMemChunk    *mem_chunk);
56 void            g_mem_chunk_info        (void);
57 void            g_blow_chunks           (void);
58
59
60 GAllocator *    g_allocator_new         (const gchar  *name,
61                                          guint         n_preallocs);
62 void            g_allocator_free        (GAllocator   *allocator);
63 void            g_list_push_allocator   (GAllocator   *allocator);
64 void            g_list_pop_allocator    (void);
65 void            g_slist_push_allocator  (GAllocator   *allocator);
66 void            g_slist_pop_allocator   (void);
67 void            g_node_push_allocator   (GAllocator   *allocator);
68 void            g_node_pop_allocator    (void);
69
70 G_END_DECLS
71
72 #endif /* __G_ALLOCATOR_H__ */