source: appstream-generator/build/girepo/glib/MemorySlice.d @ 4841

Last change on this file since 4841 was 4841, checked in by Juanma, 2 years ago

Initial release

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