1 /*
2  * This file is part of gtkD.
3  *
4  * gtkD is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU Lesser General Public License
6  * as published by the Free Software Foundation; either version 3
7  * of the License, or (at your option) any later version, with
8  * some exceptions, please read the COPYING file.
9  *
10  * gtkD is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public License
16  * along with gtkD; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA
18  */
19 
20 // generated automatically - do not change
21 // find conversion definition on APILookup.txt
22 // implement new conversion functionalities on the wrap.utils pakage
23 
24 
25 module glib.MemorySlice;
26 
27 private import gtkc.glib;
28 public  import gtkc.glibtypes;
29 
30 
31 /** */
32 public struct MemorySlice
33 {
34 	T* mewSlice(T)()
35 	{
36 		return cast(T*)g_slice_alloc(T.sizeof);
37 	}
38 	
39 	T* mewSlice0(T)()
40 	{
41 		return cast(T*)g_slice_alloc0(T.sizeof);
42 	}
43 	
44 	T* dup(T)(T* memBlock)
45 	{
46 		return cast(T*)g_slice_copy(T.sizeof, memBlock);
47 	}
48 	
49 	void free(T)(T* memBlock)
50 	{
51 		g_slice_free1(T.sizeof, memBlock);
52 	}
53 
54 	/**
55 	 */
56 
57 	/**
58 	 * Allocates a block of memory from the slice allocator.
59 	 * The block adress handed out can be expected to be aligned
60 	 * to at least 1 * sizeof (void*),
61 	 * though in general slices are 2 * sizeof (void*) bytes aligned,
62 	 * if a malloc() fallback implementation is used instead,
63 	 * the alignment may be reduced in a libc dependent fashion.
64 	 * Note that the underlying slice allocation mechanism can
65 	 * be changed with the [`G_SLICE=always-malloc`][G_SLICE]
66 	 * environment variable.
67 	 *
68 	 * Params:
69 	 *     blockSize = the number of bytes to allocate
70 	 *
71 	 * Return: a pointer to the allocated memory block
72 	 *
73 	 * Since: 2.10
74 	 */
75 	public static void* sliceAlloc(size_t blockSize)
76 	{
77 		return g_slice_alloc(blockSize);
78 	}
79 
80 	/**
81 	 * Allocates a block of memory via g_slice_alloc() and initializes
82 	 * the returned memory to 0. Note that the underlying slice allocation
83 	 * mechanism can be changed with the [`G_SLICE=always-malloc`][G_SLICE]
84 	 * environment variable.
85 	 *
86 	 * Params:
87 	 *     blockSize = the number of bytes to allocate
88 	 *
89 	 * Return: a pointer to the allocated block
90 	 *
91 	 * Since: 2.10
92 	 */
93 	public static void* sliceAlloc0(size_t blockSize)
94 	{
95 		return g_slice_alloc0(blockSize);
96 	}
97 
98 	/**
99 	 * Allocates a block of memory from the slice allocator
100 	 * and copies @block_size bytes into it from @mem_block.
101 	 *
102 	 * Params:
103 	 *     blockSize = the number of bytes to allocate
104 	 *     memBlock = the memory to copy
105 	 *
106 	 * Return: a pointer to the allocated memory block
107 	 *
108 	 * Since: 2.14
109 	 */
110 	public static void* sliceCopy(size_t blockSize, void* memBlock)
111 	{
112 		return g_slice_copy(blockSize, memBlock);
113 	}
114 
115 	/**
116 	 * Frees a block of memory.
117 	 *
118 	 * The memory must have been allocated via g_slice_alloc() or
119 	 * g_slice_alloc0() and the @block_size has to match the size
120 	 * specified upon allocation. Note that the exact release behaviour
121 	 * can be changed with the [`G_DEBUG=gc-friendly`][G_DEBUG] environment
122 	 * variable, also see [`G_SLICE`][G_SLICE] for related debugging options.
123 	 *
124 	 * Params:
125 	 *     blockSize = the size of the block
126 	 *     memBlock = a pointer to the block to free
127 	 *
128 	 * Since: 2.10
129 	 */
130 	public static void sliceFree1(size_t blockSize, void* memBlock)
131 	{
132 		g_slice_free1(blockSize, memBlock);
133 	}
134 
135 	/**
136 	 * Frees a linked list of memory blocks of structure type @type.
137 	 *
138 	 * The memory blocks must be equal-sized, allocated via
139 	 * g_slice_alloc() or g_slice_alloc0() and linked together by a
140 	 * @next pointer (similar to #GSList). The offset of the @next
141 	 * field in each block is passed as third argument.
142 	 * Note that the exact release behaviour can be changed with the
143 	 * [`G_DEBUG=gc-friendly`][G_DEBUG] environment variable, also see
144 	 * [`G_SLICE`][G_SLICE] for related debugging options.
145 	 *
146 	 * Params:
147 	 *     blockSize = the size of the blocks
148 	 *     memChain = a pointer to the first block of the chain
149 	 *     nextOffset = the offset of the @next field in the blocks
150 	 *
151 	 * Since: 2.10
152 	 */
153 	public static void sliceFreeChainWithOffset(size_t blockSize, void* memChain, size_t nextOffset)
154 	{
155 		g_slice_free_chain_with_offset(blockSize, memChain, nextOffset);
156 	}
157 
158 	/** */
159 	public static long sliceGetConfig(GSliceConfig ckey)
160 	{
161 		return g_slice_get_config(ckey);
162 	}
163 
164 	/** */
165 	public static long* sliceGetConfigState(GSliceConfig ckey, long address, uint* nValues)
166 	{
167 		return g_slice_get_config_state(ckey, address, nValues);
168 	}
169 
170 	/** */
171 	public static void sliceSetConfig(GSliceConfig ckey, long value)
172 	{
173 		g_slice_set_config(ckey, value);
174 	}
175 }