1 /*
2  * Distributed under the Boost Software License, Version 1.0.
3  *    (See accompanying file LICENSE_1_0.txt or copy at
4  *          http://www.boost.org/LICENSE_1_0.txt)
5  */
6 module glib.gslice;
7 
8 import glib.gtypes;
9 
10 
11 extern (C) {
12 
13     gpointer g_slice_alloc          	(gsize	       block_size);
14 
15     gpointer g_slice_alloc0         	(gsize         block_size);
16 
17     gpointer g_slice_copy                   (gsize         block_size,
18                                              gconstpointer mem_block);
19 
20     void     g_slice_free1          	(gsize         block_size,
21                          gpointer      mem_block);
22 
23     void     g_slice_free_chain_with_offset (gsize         block_size,
24                          gpointer      mem_chain,
25                          gsize         next_offset);
26 
27 }
28 
29 auto g_slice_new(T)() { return cast(T*)g_slice_alloc(T.sizeof); }
30 auto g_slice_new0(T)() { return cast(T*)g_slice_alloc0(T.sizeof); }
31 
32 
33 /* we go through extra hoops to ensure type safety */
34 // #define g_slice_dup(type, mem)                                  \
35 //   (1 ? (type*) g_slice_copy (sizeof (type), (mem))              \
36 //      : ((void) ((type*) 0 == (mem)), (type*) 0))
37 // #define g_slice_free(type, mem)				do {	\
38 //   if (1) g_slice_free1 (sizeof (type), (mem));			\
39 //   else   (void) ((type*) 0 == (mem)); 				\
40 // } while (0)
41 // #define g_slice_free_chain(type, mem_chain, next)	do {	\
42 //   if (1) g_slice_free_chain_with_offset (sizeof (type),		\
43 //                  (mem_chain), G_STRUCT_OFFSET (type, next)); 	\
44 //   else   (void) ((type*) 0 == (mem_chain));			\
45 // } while (0)
46 
47 
48 enum GSliceConfig {
49   G_SLICE_CONFIG_ALWAYS_MALLOC = 1,
50   G_SLICE_CONFIG_BYPASS_MAGAZINES,
51   G_SLICE_CONFIG_WORKING_SET_MSECS,
52   G_SLICE_CONFIG_COLOR_INCREMENT,
53   G_SLICE_CONFIG_CHUNK_SIZES,
54   G_SLICE_CONFIG_CONTENTION_COUNTER
55 }
56 
57 
58 deprecated extern (C) {
59 
60     void     g_slice_set_config	   (GSliceConfig ckey, gint64 value);
61 
62     gint64   g_slice_get_config	   (GSliceConfig ckey);
63 
64     gint64*  g_slice_get_config_state  (GSliceConfig ckey, gint64 address, guint *n_values);
65 
66 }