36
37
<th width="100%" align="center">GLib Reference Manual</th>
37
38
<td><a accesskey="n" href="glib-IO-Channels.html"><img src="right.png" width="24" height="24" border="0" alt="Next"></a></td>
39
<tr><td colspan="5" class="shortcuts"><nobr><a href="#id2977424" class="shortcut">Top</a>
41
<a href="#id2977801" class="shortcut">Description</a></nobr></td></tr>
40
<tr><td colspan="5" class="shortcuts">
41
<a href="#glib-Memory-Allocation.synopsis" class="shortcut">Top</a>
43
<a href="#glib-Memory-Allocation.description" class="shortcut">Description</a>
43
46
<div class="refentry" lang="en">
44
47
<a name="glib-Memory-Allocation"></a><div class="titlepage"></div>
45
48
<div class="refnamediv"><table width="100%"><tr>
48
<a name="id2977424"></a><span class="refentrytitle">Memory Allocation</span>
50
<p>Memory Allocation — general memory-handling</p>
50
<h2><span class="refentrytitle"><a name="glib-Memory-Allocation.top_of_page"></a>Memory Allocation</span></h2>
51
<p>Memory Allocation — general memory-handling</p>
52
53
<td valign="top" align="right"></td>
53
54
</tr></table></div>
54
55
<div class="refsynopsisdiv">
56
<a name="glib-Memory-Allocation.synopsis"></a><h2>Synopsis</h2>
56
57
<pre class="synopsis">
58
59
#include <glib.h>
61
#define <a class="link" href="glib-Memory-Allocation.html#g-new">g_new</a> (struct_type, n_structs)
62
#define <a class="link" href="glib-Memory-Allocation.html#g-new0">g_new0</a> (struct_type, n_structs)
63
#define <a class="link" href="glib-Memory-Allocation.html#g-renew">g_renew</a> (struct_type, mem, n_structs)
64
#define <a class="link" href="glib-Memory-Allocation.html#g-try-new">g_try_new</a> (struct_type, n_structs)
65
#define <a class="link" href="glib-Memory-Allocation.html#g-try-new0">g_try_new0</a> (struct_type, n_structs)
66
#define <a class="link" href="glib-Memory-Allocation.html#g-try-renew">g_try_renew</a> (struct_type, mem, n_structs)
68
<a class="link" href="glib-Basic-Types.html#gpointer">gpointer</a> <a class="link" href="glib-Memory-Allocation.html#g-malloc">g_malloc</a> (<a class="link" href="glib-Basic-Types.html#gsize">gsize</a> n_bytes);
69
<a class="link" href="glib-Basic-Types.html#gpointer">gpointer</a> <a class="link" href="glib-Memory-Allocation.html#g-malloc0">g_malloc0</a> (<a class="link" href="glib-Basic-Types.html#gsize">gsize</a> n_bytes);
70
<a class="link" href="glib-Basic-Types.html#gpointer">gpointer</a> <a class="link" href="glib-Memory-Allocation.html#g-realloc">g_realloc</a> (<a class="link" href="glib-Basic-Types.html#gpointer">gpointer</a> mem,
71
<a class="link" href="glib-Basic-Types.html#gsize">gsize</a> n_bytes);
72
<a class="link" href="glib-Basic-Types.html#gpointer">gpointer</a> <a class="link" href="glib-Memory-Allocation.html#g-try-malloc">g_try_malloc</a> (<a class="link" href="glib-Basic-Types.html#gsize">gsize</a> n_bytes);
73
<a class="link" href="glib-Basic-Types.html#gpointer">gpointer</a> <a class="link" href="glib-Memory-Allocation.html#g-try-malloc0">g_try_malloc0</a> (<a class="link" href="glib-Basic-Types.html#gsize">gsize</a> n_bytes);
74
<a class="link" href="glib-Basic-Types.html#gpointer">gpointer</a> <a class="link" href="glib-Memory-Allocation.html#g-try-realloc">g_try_realloc</a> (<a class="link" href="glib-Basic-Types.html#gpointer">gpointer</a> mem,
75
<a class="link" href="glib-Basic-Types.html#gsize">gsize</a> n_bytes);
77
void <a class="link" href="glib-Memory-Allocation.html#g-free">g_free</a> (<a class="link" href="glib-Basic-Types.html#gpointer">gpointer</a> mem);
78
extern gboolean <a class="link" href="glib-Memory-Allocation.html#g-mem-gc-friendly">g_mem_gc_friendly</a>;
80
#define <a class="link" href="glib-Memory-Allocation.html#g-alloca">g_alloca</a> (size)
81
#define <a class="link" href="glib-Memory-Allocation.html#g-newa">g_newa</a> (struct_type, n_structs)
83
#define <a class="link" href="glib-Memory-Allocation.html#g-memmove">g_memmove</a> (dest,src,len)
84
<a class="link" href="glib-Basic-Types.html#gpointer">gpointer</a> <a class="link" href="glib-Memory-Allocation.html#g-memdup">g_memdup</a> (<a class="link" href="glib-Basic-Types.html#gconstpointer">gconstpointer</a> mem,
85
<a class="link" href="glib-Basic-Types.html#guint">guint</a> byte_size);
87
<a class="link" href="glib-Memory-Allocation.html#GMemVTable">GMemVTable</a>;
88
void <a class="link" href="glib-Memory-Allocation.html#g-mem-set-vtable">g_mem_set_vtable</a> (<a class="link" href="glib-Memory-Allocation.html#GMemVTable">GMemVTable</a> *vtable);
89
<a class="link" href="glib-Basic-Types.html#gboolean">gboolean</a> <a class="link" href="glib-Memory-Allocation.html#g-mem-is-system-malloc">g_mem_is_system_malloc</a> (void);
91
extern GMemVTable *<a class="link" href="glib-Memory-Allocation.html#glib-mem-profiler-table">glib_mem_profiler_table</a>;
92
void <a class="link" href="glib-Memory-Allocation.html#g-mem-profile">g_mem_profile</a> (void);
61
#define <a class="link" href="glib-Memory-Allocation.html#g-new" title="g_new()">g_new</a> (struct_type, n_structs)
62
#define <a class="link" href="glib-Memory-Allocation.html#g-new0" title="g_new0()">g_new0</a> (struct_type, n_structs)
63
#define <a class="link" href="glib-Memory-Allocation.html#g-renew" title="g_renew()">g_renew</a> (struct_type, mem, n_structs)
64
#define <a class="link" href="glib-Memory-Allocation.html#g-try-new" title="g_try_new()">g_try_new</a> (struct_type, n_structs)
65
#define <a class="link" href="glib-Memory-Allocation.html#g-try-new0" title="g_try_new0()">g_try_new0</a> (struct_type, n_structs)
66
#define <a class="link" href="glib-Memory-Allocation.html#g-try-renew" title="g_try_renew()">g_try_renew</a> (struct_type, mem, n_structs)
68
<a class="link" href="glib-Basic-Types.html#gpointer" title="gpointer">gpointer</a> <a class="link" href="glib-Memory-Allocation.html#g-malloc" title="g_malloc ()">g_malloc</a> (<a class="link" href="glib-Basic-Types.html#gsize" title="gsize">gsize</a> n_bytes);
69
<a class="link" href="glib-Basic-Types.html#gpointer" title="gpointer">gpointer</a> <a class="link" href="glib-Memory-Allocation.html#g-malloc0" title="g_malloc0 ()">g_malloc0</a> (<a class="link" href="glib-Basic-Types.html#gsize" title="gsize">gsize</a> n_bytes);
70
<a class="link" href="glib-Basic-Types.html#gpointer" title="gpointer">gpointer</a> <a class="link" href="glib-Memory-Allocation.html#g-realloc" title="g_realloc ()">g_realloc</a> (<a class="link" href="glib-Basic-Types.html#gpointer" title="gpointer">gpointer</a> mem,
71
<a class="link" href="glib-Basic-Types.html#gsize" title="gsize">gsize</a> n_bytes);
72
<a class="link" href="glib-Basic-Types.html#gpointer" title="gpointer">gpointer</a> <a class="link" href="glib-Memory-Allocation.html#g-try-malloc" title="g_try_malloc ()">g_try_malloc</a> (<a class="link" href="glib-Basic-Types.html#gsize" title="gsize">gsize</a> n_bytes);
73
<a class="link" href="glib-Basic-Types.html#gpointer" title="gpointer">gpointer</a> <a class="link" href="glib-Memory-Allocation.html#g-try-malloc0" title="g_try_malloc0 ()">g_try_malloc0</a> (<a class="link" href="glib-Basic-Types.html#gsize" title="gsize">gsize</a> n_bytes);
74
<a class="link" href="glib-Basic-Types.html#gpointer" title="gpointer">gpointer</a> <a class="link" href="glib-Memory-Allocation.html#g-try-realloc" title="g_try_realloc ()">g_try_realloc</a> (<a class="link" href="glib-Basic-Types.html#gpointer" title="gpointer">gpointer</a> mem,
75
<a class="link" href="glib-Basic-Types.html#gsize" title="gsize">gsize</a> n_bytes);
77
void <a class="link" href="glib-Memory-Allocation.html#g-free" title="g_free ()">g_free</a> (<a class="link" href="glib-Basic-Types.html#gpointer" title="gpointer">gpointer</a> mem);
78
extern gboolean <a class="link" href="glib-Memory-Allocation.html#g-mem-gc-friendly" title="g_mem_gc_friendly">g_mem_gc_friendly</a>;
80
#define <a class="link" href="glib-Memory-Allocation.html#g-alloca" title="g_alloca()">g_alloca</a> (size)
81
#define <a class="link" href="glib-Memory-Allocation.html#g-newa" title="g_newa()">g_newa</a> (struct_type, n_structs)
83
#define <a class="link" href="glib-Memory-Allocation.html#g-memmove" title="g_memmove()">g_memmove</a> (dest,src,len)
84
<a class="link" href="glib-Basic-Types.html#gpointer" title="gpointer">gpointer</a> <a class="link" href="glib-Memory-Allocation.html#g-memdup" title="g_memdup ()">g_memdup</a> (<a class="link" href="glib-Basic-Types.html#gconstpointer" title="gconstpointer">gconstpointer</a> mem,
85
<a class="link" href="glib-Basic-Types.html#guint" title="guint">guint</a> byte_size);
87
<a class="link" href="glib-Memory-Allocation.html#GMemVTable" title="GMemVTable">GMemVTable</a>;
88
void <a class="link" href="glib-Memory-Allocation.html#g-mem-set-vtable" title="g_mem_set_vtable ()">g_mem_set_vtable</a> (<a class="link" href="glib-Memory-Allocation.html#GMemVTable" title="GMemVTable">GMemVTable</a> *vtable);
89
<a class="link" href="glib-Basic-Types.html#gboolean" title="gboolean">gboolean</a> <a class="link" href="glib-Memory-Allocation.html#g-mem-is-system-malloc" title="g_mem_is_system_malloc ()">g_mem_is_system_malloc</a> (void);
91
extern GMemVTable *<a class="link" href="glib-Memory-Allocation.html#glib-mem-profiler-table" title="glib_mem_profiler_table">glib_mem_profiler_table</a>;
92
void <a class="link" href="glib-Memory-Allocation.html#g-mem-profile" title="g_mem_profile ()">g_mem_profile</a> (void);
95
95
<div class="refsect1" lang="en">
96
<a name="id2977801"></a><h2>Description</h2>
96
<a name="glib-Memory-Allocation.description"></a><h2>Description</h2>
98
98
These functions provide support for allocating and freeing memory.
107
107
<div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
108
108
<h3 class="title">Note</h3>
110
It's important to match <a class="link" href="glib-Memory-Allocation.html#g-malloc"><code class="function">g_malloc()</code></a> with <a class="link" href="glib-Memory-Allocation.html#g-free"><code class="function">g_free()</code></a>, plain <code class="function">malloc()</code> with <code class="function">free()</code>,
110
It's important to match <a class="link" href="glib-Memory-Allocation.html#g-malloc" title="g_malloc ()"><code class="function">g_malloc()</code></a> with <a class="link" href="glib-Memory-Allocation.html#g-free" title="g_free ()"><code class="function">g_free()</code></a>, plain <code class="function">malloc()</code> with <code class="function">free()</code>,
111
111
and (if you're using C++) new with delete and new[] with delete[]. Otherwise
112
112
bad things can happen, since these allocators may use different memory
113
113
pools (and new/delete call constructors and destructors). See also
114
<a class="link" href="glib-Memory-Allocation.html#g-mem-set-vtable"><code class="function">g_mem_set_vtable()</code></a>.
114
<a class="link" href="glib-Memory-Allocation.html#g-mem-set-vtable" title="g_mem_set_vtable ()"><code class="function">g_mem_set_vtable()</code></a>.
118
118
<div class="refsect1" lang="en">
119
<a name="id2977891"></a><h2>Details</h2>
119
<a name="glib-Memory-Allocation.details"></a><h2>Details</h2>
120
120
<div class="refsect2" lang="en">
121
<a name="id2977901"></a><h3>
122
<a name="g-new"></a>g_new()</h3>
123
<a class="indexterm" name="id2977914"></a><pre class="programlisting">#define g_new(struct_type, n_structs)</pre>
121
<a name="g-new"></a><h3>g_new()</h3>
122
<pre class="programlisting">#define g_new(struct_type, n_structs)</pre>
125
124
Allocates <em class="parameter"><code>n_structs</code></em> elements of type <em class="parameter"><code>struct_type</code></em>.
126
125
The returned pointer is cast to a pointer to the given type.
127
If <em class="parameter"><code>n_structs</code></em> is 0 it returns <a class="link" href="glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a>.
126
If <em class="parameter"><code>n_structs</code></em> is 0 it returns <a class="link" href="glib-Standard-Macros.html#NULL--CAPS" title="NULL"><code class="literal">NULL</code></a>.
130
129
Since the returned pointer is already casted to the right type,
196
190
<div class="refsect2" lang="en">
197
<a name="id2978128"></a><h3>
198
<a name="g-renew"></a>g_renew()</h3>
199
<a class="indexterm" name="id2978140"></a><pre class="programlisting">#define g_renew(struct_type, mem, n_structs)</pre>
191
<a name="g-renew"></a><h3>g_renew()</h3>
192
<pre class="programlisting">#define g_renew(struct_type, mem, n_structs)</pre>
201
194
Reallocates the memory pointed to by <em class="parameter"><code>mem</code></em>, so that it now has space for
202
<em class="parameter"><code>n_structs</code></em> elements of type <em class="parameter"><code>struct_type</code></em>. It returns the new address of
195
<em class="parameter"><code>n_structs</code></em> elements of type <em class="parameter"><code>struct_type</code></em>. It returns the new address of
203
196
the memory, which may have been moved.
205
198
<div class="variablelist"><table border="0">
206
199
<col align="left" valign="top">
209
<td><p><span class="term"><em class="parameter"><code>struct_type</code></em> :</span></p></td>
202
<td><p><span class="term"><em class="parameter"><code>struct_type</code></em> :</span></p></td>
210
203
<td>the type of the elements to allocate
214
<td><p><span class="term"><em class="parameter"><code>mem</code></em> :</span></p></td>
207
<td><p><span class="term"><em class="parameter"><code>mem</code></em> :</span></p></td>
215
208
<td>the currently allocated memory
219
<td><p><span class="term"><em class="parameter"><code>n_structs</code></em> :</span></p></td>
212
<td><p><span class="term"><em class="parameter"><code>n_structs</code></em> :</span></p></td>
220
213
<td>the number of elements to allocate
224
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
217
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
225
218
<td>a pointer to the new allocated memory, cast to a pointer to <em class="parameter"><code>struct_type</code></em>
234
225
<div class="refsect2" lang="en">
235
<a name="id2978240"></a><h3>
236
<a name="g-try-new"></a>g_try_new()</h3>
237
<a class="indexterm" name="id2978255"></a><pre class="programlisting">#define g_try_new(struct_type, n_structs)</pre>
226
<a name="g-try-new"></a><h3>g_try_new()</h3>
227
<pre class="programlisting">#define g_try_new(struct_type, n_structs)</pre>
239
Attempts to allocate <em class="parameter"><code>n_structs</code></em> elements of type <em class="parameter"><code>struct_type</code></em>, and returns
240
<a class="link" href="glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a> on failure. Contrast with <a class="link" href="glib-Memory-Allocation.html#g-new"><code class="function">g_new()</code></a>, which aborts the program on failure.
241
The returned pointer is cast to a pointer to the given type.
242
If <em class="parameter"><code>n_structs</code></em> is 0 it returns <a class="link" href="glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a>.
229
Attempts to allocate <em class="parameter"><code>n_structs</code></em> elements of type <em class="parameter"><code>struct_type</code></em>, and returns
230
<a class="link" href="glib-Standard-Macros.html#NULL--CAPS" title="NULL"><code class="literal">NULL</code></a> on failure. Contrast with <a class="link" href="glib-Memory-Allocation.html#g-new" title="g_new()"><code class="function">g_new()</code></a>, which aborts the program on failure.
231
The returned pointer is cast to a pointer to the given type.
232
If <em class="parameter"><code>n_structs</code></em> is 0 it returns <a class="link" href="glib-Standard-Macros.html#NULL--CAPS" title="NULL"><code class="literal">NULL</code></a>.
244
234
<div class="variablelist"><table border="0">
245
235
<col align="left" valign="top">
248
<td><p><span class="term"><em class="parameter"><code>struct_type</code></em> :</span></p></td>
238
<td><p><span class="term"><em class="parameter"><code>struct_type</code></em> :</span></p></td>
249
239
<td>the type of the elements to allocate
253
<td><p><span class="term"><em class="parameter"><code>n_structs</code></em> :</span></p></td>
243
<td><p><span class="term"><em class="parameter"><code>n_structs</code></em> :</span></p></td>
254
244
<td>the number of elements to allocate
258
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
248
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
259
249
<td>a pointer to the allocated memory, cast to a pointer to <em class="parameter"><code>struct_type</code></em>
264
<p class="since">Since 2.8
254
<p class="since">Since 2.8</p>
270
257
<div class="refsect2" lang="en">
271
<a name="id2978379"></a><h3>
272
<a name="g-try-new0"></a>g_try_new0()</h3>
273
<a class="indexterm" name="id2978394"></a><pre class="programlisting">#define g_try_new0(struct_type, n_structs)</pre>
258
<a name="g-try-new0"></a><h3>g_try_new0()</h3>
259
<pre class="programlisting">#define g_try_new0(struct_type, n_structs)</pre>
275
Attempts to allocate <em class="parameter"><code>n_structs</code></em> elements of type <em class="parameter"><code>struct_type</code></em>, initialized
276
to 0's, and returns <a class="link" href="glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a> on failure. Contrast with <a class="link" href="glib-Memory-Allocation.html#g-new0"><code class="function">g_new0()</code></a>, which aborts
261
Attempts to allocate <em class="parameter"><code>n_structs</code></em> elements of type <em class="parameter"><code>struct_type</code></em>, initialized
262
to 0's, and returns <a class="link" href="glib-Standard-Macros.html#NULL--CAPS" title="NULL"><code class="literal">NULL</code></a> on failure. Contrast with <a class="link" href="glib-Memory-Allocation.html#g-new0" title="g_new0()"><code class="function">g_new0()</code></a>, which aborts
277
263
the program on failure.
278
264
The returned pointer is cast to a pointer to the given type.
279
The function returns <a class="link" href="glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a> when <em class="parameter"><code>n_structs</code></em> is 0.
265
The function returns <a class="link" href="glib-Standard-Macros.html#NULL--CAPS" title="NULL"><code class="literal">NULL</code></a> when <em class="parameter"><code>n_structs</code></em> is 0.
281
267
<div class="variablelist"><table border="0">
282
268
<col align="left" valign="top">
285
<td><p><span class="term"><em class="parameter"><code>struct_type</code></em> :</span></p></td>
271
<td><p><span class="term"><em class="parameter"><code>struct_type</code></em> :</span></p></td>
286
272
<td>the type of the elements to allocate
290
<td><p><span class="term"><em class="parameter"><code>n_structs</code></em> :</span></p></td>
276
<td><p><span class="term"><em class="parameter"><code>n_structs</code></em> :</span></p></td>
291
277
<td>the number of elements to allocate
295
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
281
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
296
282
<td>a pointer to the allocated memory, cast to a pointer to <em class="parameter"><code>struct_type</code></em>
301
<p class="since">Since 2.8
287
<p class="since">Since 2.8</p>
307
290
<div class="refsect2" lang="en">
308
<a name="id2978518"></a><h3>
309
<a name="g-try-renew"></a>g_try_renew()</h3>
310
<a class="indexterm" name="id2978532"></a><pre class="programlisting">#define g_try_renew(struct_type, mem, n_structs)</pre>
291
<a name="g-try-renew"></a><h3>g_try_renew()</h3>
292
<pre class="programlisting">#define g_try_renew(struct_type, mem, n_structs)</pre>
312
Attempts to reallocate the memory pointed to by <em class="parameter"><code>mem</code></em>, so that it now has
313
space for <em class="parameter"><code>n_structs</code></em> elements of type <em class="parameter"><code>struct_type</code></em>, and returns <a class="link" href="glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a> on
314
failure. Contrast with <a class="link" href="glib-Memory-Allocation.html#g-renew"><code class="function">g_renew()</code></a>, which aborts the program on failure.
294
Attempts to reallocate the memory pointed to by <em class="parameter"><code>mem</code></em>, so that it now has
295
space for <em class="parameter"><code>n_structs</code></em> elements of type <em class="parameter"><code>struct_type</code></em>, and returns <a class="link" href="glib-Standard-Macros.html#NULL--CAPS" title="NULL"><code class="literal">NULL</code></a> on
296
failure. Contrast with <a class="link" href="glib-Memory-Allocation.html#g-renew" title="g_renew()"><code class="function">g_renew()</code></a>, which aborts the program on failure.
315
297
It returns the new address of the memory, which may have been moved.
317
299
<div class="variablelist"><table border="0">
318
300
<col align="left" valign="top">
321
<td><p><span class="term"><em class="parameter"><code>struct_type</code></em> :</span></p></td>
303
<td><p><span class="term"><em class="parameter"><code>struct_type</code></em> :</span></p></td>
322
304
<td>the type of the elements to allocate
326
<td><p><span class="term"><em class="parameter"><code>mem</code></em> :</span></p></td>
308
<td><p><span class="term"><em class="parameter"><code>mem</code></em> :</span></p></td>
327
309
<td>the currently allocated memory
331
<td><p><span class="term"><em class="parameter"><code>n_structs</code></em> :</span></p></td>
313
<td><p><span class="term"><em class="parameter"><code>n_structs</code></em> :</span></p></td>
332
314
<td>the number of elements to allocate
336
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
318
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
337
319
<td>a pointer to the new allocated memory, cast to a pointer to <em class="parameter"><code>struct_type</code></em>
342
<p class="since">Since 2.8
324
<p class="since">Since 2.8</p>
348
327
<div class="refsect2" lang="en">
349
<a name="id2978660"></a><h3>
350
<a name="g-malloc"></a>g_malloc ()</h3>
351
<a class="indexterm" name="id2978673"></a><pre class="programlisting"><a class="link" href="glib-Basic-Types.html#gpointer">gpointer</a> g_malloc (<a class="link" href="glib-Basic-Types.html#gsize">gsize</a> n_bytes);</pre>
328
<a name="g-malloc"></a><h3>g_malloc ()</h3>
329
<pre class="programlisting"><a class="link" href="glib-Basic-Types.html#gpointer" title="gpointer">gpointer</a> g_malloc (<a class="link" href="glib-Basic-Types.html#gsize" title="gsize">gsize</a> n_bytes);</pre>
353
331
Allocates <em class="parameter"><code>n_bytes</code></em> bytes of memory.
354
If <em class="parameter"><code>n_bytes</code></em> is 0 it returns <a class="link" href="glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a>.
332
If <em class="parameter"><code>n_bytes</code></em> is 0 it returns <a class="link" href="glib-Standard-Macros.html#NULL--CAPS" title="NULL"><code class="literal">NULL</code></a>.
356
334
<div class="variablelist"><table border="0">
357
335
<col align="left" valign="top">
360
<td><p><span class="term"><em class="parameter"><code>n_bytes</code></em> :</span></p></td>
338
<td><p><span class="term"><em class="parameter"><code>n_bytes</code></em> :</span></p></td>
361
339
<td>the number of bytes to allocate
365
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
343
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
366
344
<td>a pointer to the allocated memory
402
375
<div class="refsect2" lang="en">
403
<a name="id2978846"></a><h3>
404
<a name="g-realloc"></a>g_realloc ()</h3>
405
<a class="indexterm" name="id2978859"></a><pre class="programlisting"><a class="link" href="glib-Basic-Types.html#gpointer">gpointer</a> g_realloc (<a class="link" href="glib-Basic-Types.html#gpointer">gpointer</a> mem,
406
<a class="link" href="glib-Basic-Types.html#gsize">gsize</a> n_bytes);</pre>
376
<a name="g-realloc"></a><h3>g_realloc ()</h3>
377
<pre class="programlisting"><a class="link" href="glib-Basic-Types.html#gpointer" title="gpointer">gpointer</a> g_realloc (<a class="link" href="glib-Basic-Types.html#gpointer" title="gpointer">gpointer</a> mem,
378
<a class="link" href="glib-Basic-Types.html#gsize" title="gsize">gsize</a> n_bytes);</pre>
408
380
Reallocates the memory pointed to by <em class="parameter"><code>mem</code></em>, so that it now has space for
409
381
<em class="parameter"><code>n_bytes</code></em> bytes of memory. It returns the new address of the memory, which may
410
have been moved. <em class="parameter"><code>mem</code></em> may be <a class="link" href="glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a>, in which case it's considered to
411
have zero-length. <em class="parameter"><code>n_bytes</code></em> may be 0, in which case <a class="link" href="glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a> will be returned
412
and <em class="parameter"><code>mem</code></em> will be freed unless it is <a class="link" href="glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a>.
382
have been moved. <em class="parameter"><code>mem</code></em> may be <a class="link" href="glib-Standard-Macros.html#NULL--CAPS" title="NULL"><code class="literal">NULL</code></a>, in which case it's considered to
383
have zero-length. <em class="parameter"><code>n_bytes</code></em> may be 0, in which case <a class="link" href="glib-Standard-Macros.html#NULL--CAPS" title="NULL"><code class="literal">NULL</code></a> will be returned
384
and <em class="parameter"><code>mem</code></em> will be freed unless it is <a class="link" href="glib-Standard-Macros.html#NULL--CAPS" title="NULL"><code class="literal">NULL</code></a>.
414
386
<div class="variablelist"><table border="0">
415
387
<col align="left" valign="top">
418
<td><p><span class="term"><em class="parameter"><code>mem</code></em> :</span></p></td>
390
<td><p><span class="term"><em class="parameter"><code>mem</code></em> :</span></p></td>
419
391
<td>the memory to reallocate
423
<td><p><span class="term"><em class="parameter"><code>n_bytes</code></em> :</span></p></td>
395
<td><p><span class="term"><em class="parameter"><code>n_bytes</code></em> :</span></p></td>
424
396
<td>new size of the memory in bytes
428
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
400
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
429
401
<td>the new address of the allocated memory
438
408
<div class="refsect2" lang="en">
439
<a name="id2979002"></a><h3>
440
<a name="g-try-malloc"></a>g_try_malloc ()</h3>
441
<a class="indexterm" name="id2979015"></a><pre class="programlisting"><a class="link" href="glib-Basic-Types.html#gpointer">gpointer</a> g_try_malloc (<a class="link" href="glib-Basic-Types.html#gsize">gsize</a> n_bytes);</pre>
409
<a name="g-try-malloc"></a><h3>g_try_malloc ()</h3>
410
<pre class="programlisting"><a class="link" href="glib-Basic-Types.html#gpointer" title="gpointer">gpointer</a> g_try_malloc (<a class="link" href="glib-Basic-Types.html#gsize" title="gsize">gsize</a> n_bytes);</pre>
443
Attempts to allocate <em class="parameter"><code>n_bytes</code></em>, and returns <a class="link" href="glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a> on failure.
444
Contrast with <a class="link" href="glib-Memory-Allocation.html#g-malloc"><code class="function">g_malloc()</code></a>, which aborts the program on failure.
412
Attempts to allocate <em class="parameter"><code>n_bytes</code></em>, and returns <a class="link" href="glib-Standard-Macros.html#NULL--CAPS" title="NULL"><code class="literal">NULL</code></a> on failure.
413
Contrast with <a class="link" href="glib-Memory-Allocation.html#g-malloc" title="g_malloc ()"><code class="function">g_malloc()</code></a>, which aborts the program on failure.
446
415
<div class="variablelist"><table border="0">
447
416
<col align="left" valign="top">
450
<td><p><span class="term"><em class="parameter"><code>n_bytes</code></em> :</span></p></td>
419
<td><p><span class="term"><em class="parameter"><code>n_bytes</code></em> :</span></p></td>
451
420
<td>number of bytes to allocate.
455
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
456
<td>the allocated memory, or <a class="link" href="glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a>.
424
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
425
<td>the allocated memory, or <a class="link" href="glib-Standard-Macros.html#NULL--CAPS" title="NULL"><code class="literal">NULL</code></a>.
465
432
<div class="refsect2" lang="en">
466
<a name="id2979110"></a><h3>
467
<a name="g-try-malloc0"></a>g_try_malloc0 ()</h3>
468
<a class="indexterm" name="id2979125"></a><pre class="programlisting"><a class="link" href="glib-Basic-Types.html#gpointer">gpointer</a> g_try_malloc0 (<a class="link" href="glib-Basic-Types.html#gsize">gsize</a> n_bytes);</pre>
433
<a name="g-try-malloc0"></a><h3>g_try_malloc0 ()</h3>
434
<pre class="programlisting"><a class="link" href="glib-Basic-Types.html#gpointer" title="gpointer">gpointer</a> g_try_malloc0 (<a class="link" href="glib-Basic-Types.html#gsize" title="gsize">gsize</a> n_bytes);</pre>
470
Attempts to allocate <em class="parameter"><code>n_bytes</code></em>, initialized to 0's, and returns <a class="link" href="glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a> on
471
failure. Contrast with <a class="link" href="glib-Memory-Allocation.html#g-malloc0"><code class="function">g_malloc0()</code></a>, which aborts the program on failure.
436
Attempts to allocate <em class="parameter"><code>n_bytes</code></em>, initialized to 0's, and returns <a class="link" href="glib-Standard-Macros.html#NULL--CAPS" title="NULL"><code class="literal">NULL</code></a> on
437
failure. Contrast with <a class="link" href="glib-Memory-Allocation.html#g-malloc0" title="g_malloc0 ()"><code class="function">g_malloc0()</code></a>, which aborts the program on failure.
473
439
<div class="variablelist"><table border="0">
474
440
<col align="left" valign="top">
477
<td><p><span class="term"><em class="parameter"><code>n_bytes</code></em> :</span></p></td>
443
<td><p><span class="term"><em class="parameter"><code>n_bytes</code></em> :</span></p></td>
478
444
<td>number of bytes to allocate
482
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
483
<td>the allocated memory, or <a class="link" href="glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a>
448
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
449
<td>the allocated memory, or <a class="link" href="glib-Standard-Macros.html#NULL--CAPS" title="NULL"><code class="literal">NULL</code></a>
488
<p class="since">Since 2.8
454
<p class="since">Since 2.8</p>
494
457
<div class="refsect2" lang="en">
495
<a name="id2979228"></a><h3>
496
<a name="g-try-realloc"></a>g_try_realloc ()</h3>
497
<a class="indexterm" name="id2979241"></a><pre class="programlisting"><a class="link" href="glib-Basic-Types.html#gpointer">gpointer</a> g_try_realloc (<a class="link" href="glib-Basic-Types.html#gpointer">gpointer</a> mem,
498
<a class="link" href="glib-Basic-Types.html#gsize">gsize</a> n_bytes);</pre>
458
<a name="g-try-realloc"></a><h3>g_try_realloc ()</h3>
459
<pre class="programlisting"><a class="link" href="glib-Basic-Types.html#gpointer" title="gpointer">gpointer</a> g_try_realloc (<a class="link" href="glib-Basic-Types.html#gpointer" title="gpointer">gpointer</a> mem,
460
<a class="link" href="glib-Basic-Types.html#gsize" title="gsize">gsize</a> n_bytes);</pre>
500
Attempts to realloc <em class="parameter"><code>mem</code></em> to a new size, <em class="parameter"><code>n_bytes</code></em>, and returns <a class="link" href="glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a>
501
on failure. Contrast with <a class="link" href="glib-Memory-Allocation.html#g-realloc"><code class="function">g_realloc()</code></a>, which aborts the program
502
on failure. If <em class="parameter"><code>mem</code></em> is <a class="link" href="glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a>, behaves the same as <a class="link" href="glib-Memory-Allocation.html#g-try-malloc"><code class="function">g_try_malloc()</code></a>.
462
Attempts to realloc <em class="parameter"><code>mem</code></em> to a new size, <em class="parameter"><code>n_bytes</code></em>, and returns <a class="link" href="glib-Standard-Macros.html#NULL--CAPS" title="NULL"><code class="literal">NULL</code></a>
463
on failure. Contrast with <a class="link" href="glib-Memory-Allocation.html#g-realloc" title="g_realloc ()"><code class="function">g_realloc()</code></a>, which aborts the program
464
on failure. If <em class="parameter"><code>mem</code></em> is <a class="link" href="glib-Standard-Macros.html#NULL--CAPS" title="NULL"><code class="literal">NULL</code></a>, behaves the same as <a class="link" href="glib-Memory-Allocation.html#g-try-malloc" title="g_try_malloc ()"><code class="function">g_try_malloc()</code></a>.
504
466
<div class="variablelist"><table border="0">
505
467
<col align="left" valign="top">
508
<td><p><span class="term"><em class="parameter"><code>mem</code></em> :</span></p></td>
509
<td>previously-allocated memory, or <a class="link" href="glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a>.
470
<td><p><span class="term"><em class="parameter"><code>mem</code></em> :</span></p></td>
471
<td>previously-allocated memory, or <a class="link" href="glib-Standard-Macros.html#NULL--CAPS" title="NULL"><code class="literal">NULL</code></a>.
513
<td><p><span class="term"><em class="parameter"><code>n_bytes</code></em> :</span></p></td>
475
<td><p><span class="term"><em class="parameter"><code>n_bytes</code></em> :</span></p></td>
514
476
<td>number of bytes to allocate.
518
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
519
<td>the allocated memory, or <a class="link" href="glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a>.
480
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
481
<td>the allocated memory, or <a class="link" href="glib-Standard-Macros.html#NULL--CAPS" title="NULL"><code class="literal">NULL</code></a>.
528
488
<div class="refsect2" lang="en">
529
<a name="id2979400"></a><h3>
530
<a name="g-free"></a>g_free ()</h3>
531
<a class="indexterm" name="id2979412"></a><pre class="programlisting">void g_free (<a class="link" href="glib-Basic-Types.html#gpointer">gpointer</a> mem);</pre>
489
<a name="g-free"></a><h3>g_free ()</h3>
490
<pre class="programlisting">void g_free (<a class="link" href="glib-Basic-Types.html#gpointer" title="gpointer">gpointer</a> mem);</pre>
533
492
Frees the memory pointed to by <em class="parameter"><code>mem</code></em>.
534
If <em class="parameter"><code>mem</code></em> is <a class="link" href="glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a> it simply returns.
493
If <em class="parameter"><code>mem</code></em> is <a class="link" href="glib-Standard-Macros.html#NULL--CAPS" title="NULL"><code class="literal">NULL</code></a> it simply returns.
536
495
<div class="variablelist"><table border="0">
537
496
<col align="left" valign="top">
539
<td><p><span class="term"><em class="parameter"><code>mem</code></em> :</span></p></td>
498
<td><p><span class="term"><em class="parameter"><code>mem</code></em> :</span></p></td>
540
499
<td>the memory to free
548
505
<div class="refsect2" lang="en">
549
<a name="id2979481"></a><h3>
550
<a name="g-mem-gc-friendly"></a>g_mem_gc_friendly</h3>
551
<a class="indexterm" name="id2979494"></a><pre class="programlisting">extern gboolean g_mem_gc_friendly;
506
<a name="g-mem-gc-friendly"></a><h3>g_mem_gc_friendly</h3>
507
<pre class="programlisting">extern gboolean g_mem_gc_friendly;
554
This variable is <a class="link" href="glib-Standard-Macros.html#TRUE:CAPS"><code class="literal">TRUE</code></a> if the <code class="envar">G_DEBUG</code> environment variable
555
includes the key <a class="link" href="glib-running.html#G_DEBUG" title="G_DEBUG">gc-friendly</a>.
510
This variable is <a class="link" href="glib-Standard-Macros.html#TRUE--CAPS" title="TRUE"><code class="literal">TRUE</code></a> if the <code class="envar">G_DEBUG</code> environment variable
511
includes the key <a class="link" href="glib-running.html#G_DEBUG" title="G_DEBUG">gc-friendly</a>.
559
515
<div class="refsect2" lang="en">
560
<a name="id2979533"></a><h3>
561
<a name="g-alloca"></a>g_alloca()</h3>
562
<a class="indexterm" name="id2979545"></a><pre class="programlisting">#define g_alloca(size)</pre>
516
<a name="g-alloca"></a><h3>g_alloca()</h3>
517
<pre class="programlisting">#define g_alloca(size)</pre>
564
519
Allocates <em class="parameter"><code>size</code></em> bytes on the stack; these bytes will be freed when the current
565
stack frame is cleaned up. This macro essentially just wraps the <code class="function">alloca()</code>
566
function present on most UNIX variants.
520
stack frame is cleaned up. This macro essentially just wraps the <code class="function">alloca()</code>
521
function present on most UNIX variants.
567
522
Thus it provides the same advantages and pitfalls as <code class="function">alloca()</code>:
569
524
<div class="variablelist"><table border="0">
705
652
<div class="refsect2" lang="en">
706
<a name="id2979972"></a><h3>
707
<a name="g-memdup"></a>g_memdup ()</h3>
708
<a class="indexterm" name="id2979985"></a><pre class="programlisting"><a class="link" href="glib-Basic-Types.html#gpointer">gpointer</a> g_memdup (<a class="link" href="glib-Basic-Types.html#gconstpointer">gconstpointer</a> mem,
709
<a class="link" href="glib-Basic-Types.html#guint">guint</a> byte_size);</pre>
653
<a name="g-memdup"></a><h3>g_memdup ()</h3>
654
<pre class="programlisting"><a class="link" href="glib-Basic-Types.html#gpointer" title="gpointer">gpointer</a> g_memdup (<a class="link" href="glib-Basic-Types.html#gconstpointer" title="gconstpointer">gconstpointer</a> mem,
655
<a class="link" href="glib-Basic-Types.html#guint" title="guint">guint</a> byte_size);</pre>
711
657
Allocates <em class="parameter"><code>byte_size</code></em> bytes of memory, and copies <em class="parameter"><code>byte_size</code></em> bytes into it
712
from <em class="parameter"><code>mem</code></em>. If <em class="parameter"><code>mem</code></em> is <a class="link" href="glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a> it returns <a class="link" href="glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a>.
658
from <em class="parameter"><code>mem</code></em>. If <em class="parameter"><code>mem</code></em> is <a class="link" href="glib-Standard-Macros.html#NULL--CAPS" title="NULL"><code class="literal">NULL</code></a> it returns <a class="link" href="glib-Standard-Macros.html#NULL--CAPS" title="NULL"><code class="literal">NULL</code></a>.
714
660
<div class="variablelist"><table border="0">
715
661
<col align="left" valign="top">
718
<td><p><span class="term"><em class="parameter"><code>mem</code></em> :</span></p></td>
664
<td><p><span class="term"><em class="parameter"><code>mem</code></em> :</span></p></td>
719
665
<td>the memory to copy.
723
<td><p><span class="term"><em class="parameter"><code>byte_size</code></em> :</span></p></td>
669
<td><p><span class="term"><em class="parameter"><code>byte_size</code></em> :</span></p></td>
724
670
<td>the number of bytes to copy.
728
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
729
<td>a pointer to the newly-allocated copy of the memory, or <a class="link" href="glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a> if <em class="parameter"><code>mem</code></em>
730
is <a class="link" href="glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a>.
674
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
675
<td>a pointer to the newly-allocated copy of the memory, or <a class="link" href="glib-Standard-Macros.html#NULL--CAPS" title="NULL"><code class="literal">NULL</code></a> if <em class="parameter"><code>mem</code></em>
676
is <a class="link" href="glib-Standard-Macros.html#NULL--CAPS" title="NULL"><code class="literal">NULL</code></a>.
756
A set of functions used to perform memory allocation. The same <a class="link" href="glib-Memory-Allocation.html#GMemVTable"><span class="type">GMemVTable</span></a> must
757
be used for all allocations in the same program; a call to <a class="link" href="glib-Memory-Allocation.html#g-mem-set-vtable"><code class="function">g_mem_set_vtable()</code></a>,
699
A set of functions used to perform memory allocation. The same <a class="link" href="glib-Memory-Allocation.html#GMemVTable" title="GMemVTable"><span class="type">GMemVTable</span></a> must
700
be used for all allocations in the same program; a call to <a class="link" href="glib-Memory-Allocation.html#g-mem-set-vtable" title="g_mem_set_vtable ()"><code class="function">g_mem_set_vtable()</code></a>,
758
701
if it exists, should be prior to any use of GLib.
760
703
<div class="variablelist"><table border="0">
761
704
<col align="left" valign="top">
764
<td><p><span class="term"><em class="structfield"><code>malloc</code></em> ()</span></p></td>
707
<td><p><span class="term"><em class="structfield"><code>malloc</code></em> ()</span></p></td>
765
708
<td>function to use for allocating memory.
769
<td><p><span class="term"><em class="structfield"><code>realloc</code></em> ()</span></p></td>
712
<td><p><span class="term"><em class="structfield"><code>realloc</code></em> ()</span></p></td>
770
713
<td>function to use for reallocating memory.
774
<td><p><span class="term"><em class="structfield"><code>free</code></em> ()</span></p></td>
717
<td><p><span class="term"><em class="structfield"><code>free</code></em> ()</span></p></td>
775
718
<td>function to use to free memory.
779
<td><p><span class="term"><em class="structfield"><code>calloc</code></em> ()</span></p></td>
722
<td><p><span class="term"><em class="structfield"><code>calloc</code></em> ()</span></p></td>
780
723
<td>function to use for allocating zero-filled memory.
784
<td><p><span class="term"><em class="structfield"><code>try_malloc</code></em> ()</span></p></td>
727
<td><p><span class="term"><em class="structfield"><code>try_malloc</code></em> ()</span></p></td>
785
728
<td>function to use for allocating memory without a default error handler.
789
<td><p><span class="term"><em class="structfield"><code>try_realloc</code></em> ()</span></p></td>
732
<td><p><span class="term"><em class="structfield"><code>try_realloc</code></em> ()</span></p></td>
790
733
<td>function to use for reallocating memory without a default error handler.
798
740
<div class="refsect2" lang="en">
799
<a name="id2980282"></a><h3>
800
<a name="g-mem-set-vtable"></a>g_mem_set_vtable ()</h3>
801
<a class="indexterm" name="id2980294"></a><pre class="programlisting">void g_mem_set_vtable (<a class="link" href="glib-Memory-Allocation.html#GMemVTable">GMemVTable</a> *vtable);</pre>
741
<a name="g-mem-set-vtable"></a><h3>g_mem_set_vtable ()</h3>
742
<pre class="programlisting">void g_mem_set_vtable (<a class="link" href="glib-Memory-Allocation.html#GMemVTable" title="GMemVTable">GMemVTable</a> *vtable);</pre>
803
Sets the <a class="link" href="glib-Memory-Allocation.html#GMemVTable"><span class="type">GMemVTable</span></a> to use for memory allocation. You can use this to provide
804
custom memory allocation routines. <span class="emphasis"><em>This function must be called
805
before using any other GLib functions.</em></span> The <em class="parameter"><code>vtable</code></em> only needs to
806
provide <code class="function">malloc()</code>, <code class="function">realloc()</code>, and <code class="function">free()</code> functions; GLib can provide default
807
implementations of the others. The <code class="function">malloc()</code> and <code class="function">realloc()</code> implementations
808
should return <a class="link" href="glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a> on failure, GLib will handle error-checking for you.
744
Sets the <a class="link" href="glib-Memory-Allocation.html#GMemVTable" title="GMemVTable"><span class="type">GMemVTable</span></a> to use for memory allocation. You can use this to provide
745
custom memory allocation routines. <span class="emphasis"><em>This function must be called
746
before using any other GLib functions.</em></span> The <em class="parameter"><code>vtable</code></em> only needs to
747
provide <code class="function">malloc()</code>, <code class="function">realloc()</code>, and <code class="function">free()</code> functions; GLib can provide default
748
implementations of the others. The <code class="function">malloc()</code> and <code class="function">realloc()</code> implementations
749
should return <a class="link" href="glib-Standard-Macros.html#NULL--CAPS" title="NULL"><code class="literal">NULL</code></a> on failure, GLib will handle error-checking for you.
809
750
<em class="parameter"><code>vtable</code></em> is copied, so need not persist after this function has been called.
811
752
<div class="variablelist"><table border="0">
812
753
<col align="left" valign="top">
814
<td><p><span class="term"><em class="parameter"><code>vtable</code></em> :</span></p></td>
755
<td><p><span class="term"><em class="parameter"><code>vtable</code></em> :</span></p></td>
815
756
<td>table of memory allocation routines.
823
762
<div class="refsect2" lang="en">
824
<a name="id2980434"></a><h3>
825
<a name="g-mem-is-system-malloc"></a>g_mem_is_system_malloc ()</h3>
826
<a class="indexterm" name="id2980448"></a><pre class="programlisting"><a class="link" href="glib-Basic-Types.html#gboolean">gboolean</a> g_mem_is_system_malloc (void);</pre>
763
<a name="g-mem-is-system-malloc"></a><h3>g_mem_is_system_malloc ()</h3>
764
<pre class="programlisting"><a class="link" href="glib-Basic-Types.html#gboolean" title="gboolean">gboolean</a> g_mem_is_system_malloc (void);</pre>
828
Checks whether the allocator used by <a class="link" href="glib-Memory-Allocation.html#g-malloc"><code class="function">g_malloc()</code></a> is the system's
829
malloc implementation. If it returns <a class="link" href="glib-Standard-Macros.html#TRUE:CAPS"><code class="literal">TRUE</code></a> memory allocated with
830
<code class="function">malloc()</code> can be used interchangeable with memory allocated using <a class="link" href="glib-Memory-Allocation.html#g-malloc"><code class="function">g_malloc()</code></a>.
766
Checks whether the allocator used by <a class="link" href="glib-Memory-Allocation.html#g-malloc" title="g_malloc ()"><code class="function">g_malloc()</code></a> is the system's
767
malloc implementation. If it returns <a class="link" href="glib-Standard-Macros.html#TRUE--CAPS" title="TRUE"><code class="literal">TRUE</code></a> memory allocated with
768
<code class="function">malloc()</code> can be used interchangeable with memory allocated using <a class="link" href="glib-Memory-Allocation.html#g-malloc" title="g_malloc ()"><code class="function">g_malloc()</code></a>.
831
769
This function is useful for avoiding an extra copy of allocated memory returned
832
770
by a non-GLib-based API.
835
A different allocator can be set using <a class="link" href="glib-Memory-Allocation.html#g-mem-set-vtable"><code class="function">g_mem_set_vtable()</code></a>.</p>
773
A different allocator can be set using <a class="link" href="glib-Memory-Allocation.html#g-mem-set-vtable" title="g_mem_set_vtable ()"><code class="function">g_mem_set_vtable()</code></a>.</p>
839
776
<div class="variablelist"><table border="0">
840
777
<col align="left" valign="top">
842
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
843
<td> if <a class="link" href="glib-Standard-Macros.html#TRUE:CAPS"><code class="literal">TRUE</code></a>, <code class="function">malloc()</code> and <a class="link" href="glib-Memory-Allocation.html#g-malloc"><code class="function">g_malloc()</code></a> can be mixed.
779
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
780
<td> if <a class="link" href="glib-Standard-Macros.html#TRUE--CAPS" title="TRUE"><code class="literal">TRUE</code></a>, <code class="function">malloc()</code> and <a class="link" href="glib-Memory-Allocation.html#g-malloc" title="g_malloc ()"><code class="function">g_malloc()</code></a> can be mixed.
849
786
<div class="refsect2" lang="en">
850
<a name="id2980578"></a><h3>
851
<a name="glib-mem-profiler-table"></a>glib_mem_profiler_table</h3>
852
<a class="indexterm" name="id2980590"></a><pre class="programlisting">extern GMemVTable *glib_mem_profiler_table;
787
<a name="glib-mem-profiler-table"></a><h3>glib_mem_profiler_table</h3>
788
<pre class="programlisting">extern GMemVTable *glib_mem_profiler_table;
855
A <a class="link" href="glib-Memory-Allocation.html#GMemVTable"><span class="type">GMemVTable</span></a> containing profiling variants of the memory
856
allocation functions. Use them together with <a class="link" href="glib-Memory-Allocation.html#g-mem-profile"><code class="function">g_mem_profile()</code></a>
791
A <a class="link" href="glib-Memory-Allocation.html#GMemVTable" title="GMemVTable"><span class="type">GMemVTable</span></a> containing profiling variants of the memory
792
allocation functions. Use them together with <a class="link" href="glib-Memory-Allocation.html#g-mem-profile" title="g_mem_profile ()"><code class="function">g_mem_profile()</code></a>
857
793
in order to get information about the memory allocation pattern
862
798
<div class="refsect2" lang="en">
863
<a name="id2980627"></a><h3>
864
<a name="g-mem-profile"></a>g_mem_profile ()</h3>
865
<a class="indexterm" name="id2980640"></a><pre class="programlisting">void g_mem_profile (void);</pre>
799
<a name="g-mem-profile"></a><h3>g_mem_profile ()</h3>
800
<pre class="programlisting">void g_mem_profile (void);</pre>
867
802
Outputs a summary of memory usage.