2 * This file is part of duit.
4 * duit 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 2.1 of the License, or
7 * (at your option) any later version.
9 * duit 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.
14 * You should have received a copy of the GNU Lesser General Public License
15 * along with duit; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 // generated automatically - do not change
20 // find conversion definition on APILookup.txt
21 // implement new conversion functionalities on the wrap.utils pakage
24 * Conversion parameters:
25 * inFile = glib-Memory-Allocation.html
50 private import glib
.glibtypes
;
52 private import lib
.glib
;
57 * These functions provide support for allocating and freeing memory.
59 * If any call to allocate memory fails, the application is terminated.
60 * This also means that there is no need to check if the call succeeded.
75 * Allocates n_bytes bytes of memory.
76 * If n_bytes is 0 it returns NULL.
78 * the number of bytes to allocate.
80 * a pointer to the allocated memory.
82 public static void* malloc(uint nBytes
)
84 // gpointer g_malloc (gulong n_bytes);
85 return g_malloc(nBytes
);
89 * Allocates n_bytes bytes of memory, initialized to 0's.
90 * If n_bytes is 0 it returns NULL.
92 * the number of bytes to allocate.
94 * a pointer to the allocated memory.
96 public static void* malloc0(uint nBytes
)
98 // gpointer g_malloc0 (gulong n_bytes);
99 return g_malloc0(nBytes
);
103 * Reallocates the memory pointed to by mem, so that it now has space for
104 * n_bytes bytes of memory. It returns the new address of the memory, which may
105 * have been moved. mem may be NULL, in which case it's considered to
106 * have zero-length. n_bytes may be 0, in which case NULL will be returned.
108 * the memory to reallocate.
110 * new size of the memory in bytes.
112 * the new address of the allocated memory.
114 public static void* realloc(void* mem
, uint nBytes
)
116 // gpointer g_realloc (gpointer mem, gulong n_bytes);
117 return g_realloc(mem
, nBytes
);
121 * Attempts to allocate n_bytes, and returns NULL on failure.
122 * Contrast with g_malloc(), which aborts the program on failure.
124 * number of bytes to allocate.
126 * the allocated memory, or NULL.
128 public static void* tryMalloc(uint nBytes
)
130 // gpointer g_try_malloc (gulong n_bytes);
131 return g_try_malloc(nBytes
);
135 * Attempts to allocate n_bytes, initialized to 0's, and returns NULL on
136 * failure. Contrast with g_malloc0(), which aborts the program on failure.
138 * number of bytes to allocate.
140 * the allocated memory, or NULL.
143 public static void* tryMalloc0(uint nBytes
)
145 // gpointer g_try_malloc0 (gulong n_bytes);
146 return g_try_malloc0(nBytes
);
150 * Attempts to realloc mem to a new size, n_bytes, and returns NULL
151 * on failure. Contrast with g_realloc(), which aborts the program
152 * on failure. If mem is NULL, behaves the same as g_try_malloc().
154 * previously-allocated memory, or NULL.
156 * number of bytes to allocate.
158 * the allocated memory, or NULL.
160 public static void* tryRealloc(void* mem
, uint nBytes
)
162 // gpointer g_try_realloc (gpointer mem, gulong n_bytes);
163 return g_try_realloc(mem
, nBytes
);
167 * Frees the memory pointed to by mem.
168 * If mem is NULL it simply returns.
170 * the memory to free.
172 public static void free(void* mem
)
174 // void g_free (gpointer mem);
183 * Allocates byte_size bytes of memory, and copies byte_size bytes into it
184 * from mem. If mem is NULL it returns NULL.
186 * the memory to copy.
188 * the number of bytes to copy.
190 * a pointer to the newly-allocated copy of the memory, or NULL if mem
193 public static void* memdup(void* mem
, uint byteSize
)
195 // gpointer g_memdup (gconstpointer mem, guint byte_size);
196 return g_memdup(mem
, byteSize
);
201 * Sets the GMemVTable to use for memory allocation. You can use this to provide
202 * custom memory allocation routines. This function must be called before using any other GLib functions. The vtable only needs to provide malloc(), realloc(), and free()
203 * functions; GLib can provide default implementations of the others. The malloc()
204 * and realloc() implementations should return NULL on failure, GLib will handle
205 * error-checking for you. vtable is copied, so need not persist after this
206 * function has been called.
208 * table of memory allocation routines.
210 public static void memSetVtable(GMemVTable
* vtable
)
212 // void g_mem_set_vtable (GMemVTable *vtable);
213 g_mem_set_vtable(vtable
);
217 * Checks whether the allocator used by g_malloc() is the system's
218 * malloc implementation. If it returns TRUE memory allocated with
219 * malloc() can be used interchangeable with memory allocated using g_malloc().
220 * This function is useful for avoiding an extra copy of allocated memory returned
221 * by a non-GLib-based API.
222 * A different allocator can be set using g_mem_set_vtable().
224 * if TRUE, malloc() and g_malloc() can be mixed.
226 public static int memIsSystemMalloc()
228 // gboolean g_mem_is_system_malloc (void);
229 return g_mem_is_system_malloc();
234 * Outputs a summary of memory usage.
235 * It outputs the frequency of allocations of different sizes,
236 * the total number of bytes which have been allocated,
237 * the total number of bytes which have been freed,
238 * and the difference between the previous two values, i.e. the number of bytes
240 * Note that this function will not output anything unless you have
241 * previously installed the glib_mem_profiler_table with g_mem_set_vtable().
243 public static void memProfile()
245 // void g_mem_profile (void);