1 /* GLIB sliced memory - fast threaded memory chunk allocator
2 * Copyright (C) 2005 Tim Janik
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the
16 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 * Boston, MA 02111-1307, USA.
23 #error Include <glib.h> instead of <gslice.h>
26 #include <glib/gtypes.h>
30 /* slices - fast allocation/release of small memory blocks
32 gpointer g_slice_alloc (gsize block_size) G_GNUC_MALLOC;
33 gpointer g_slice_alloc0 (gsize block_size) G_GNUC_MALLOC;
34 void g_slice_free1 (gsize block_size,
36 void g_slice_free_chain (gsize block_size,
39 #define g_slice_new(type) ((type*) g_slice_alloc (sizeof (type)))
40 #define g_slice_new0(type) ((type*) g_slice_alloc0 (sizeof (type)))
41 /* g_slice_free(type,mem) g_slice_free1 (sizeof (type), mem) */
44 /* for GCC, define a type-safe variant of g_slice_free() */
45 #define g_slice_free(type, mem) ({ \
46 static inline void g_slice_free (gsize, type*); \
47 while (0) g_slice_free (sizeof (type), mem); \
48 g_slice_free1 (sizeof (type), mem); \
51 #define g_slice_free(type, mem) g_slice_free1 (sizeof (type) + (gsize) (type*) 0, mem)
52 /* we go through the extra (gsize)(type*)0 hoop to ensure a known type argument */
55 /* --- internal debugging API --- */
57 G_SLICE_CONFIG_ALWAYS_MALLOC = 1,
58 G_SLICE_CONFIG_BYPASS_MAGAZINES,
59 G_SLICE_CONFIG_ALWAYS_FREE,
60 G_SLICE_CONFIG_WORKING_SET_MSECS,
61 G_SLICE_CONFIG_CHUNK_SIZES,
62 G_SLICE_CONFIG_CONTENTION_COUNTER,
64 void g_slice_set_config (GSliceConfig ckey, gint64 value);
65 gint64 g_slice_get_config (GSliceConfig ckey);
66 gint64* g_slice_get_config_state (GSliceConfig ckey, gint64 address, guint *n_values);
70 #endif /* __G_SLICE_H__ */