~ubuntu-branches/debian/jessie/glib2.0/jessie

« back to all changes in this revision

Viewing changes to docs/reference/glib/html/glib-Memory-Allocation.html

  • Committer: Bazaar Package Importer
  • Author(s): Gustavo Noronha Silva
  • Date: 2009-02-15 13:00:43 UTC
  • mto: (1.4.3 upstream)
  • mto: This revision was merged to the branch mainline in revision 70.
  • Revision ID: james.westby@ubuntu.com-20090215130043-6snh45flhit8oalb
Tags: upstream-2.18.4
Import upstream version 2.18.4

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
2
2
<html>
3
3
<head>
4
 
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
 
4
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
5
5
<title>Memory Allocation</title>
6
 
<meta name="generator" content="DocBook XSL Stylesheets V1.73.2">
7
 
<link rel="start" href="index.html" title="GLib Reference Manual">
 
6
<meta name="generator" content="DocBook XSL Stylesheets V1.74.0">
 
7
<link rel="home" href="index.html" title="GLib Reference Manual">
8
8
<link rel="up" href="glib-core.html" title="GLib Core Application Support">
9
9
<link rel="prev" href="glib-Dynamic-Loading-of-Modules.html" title="Dynamic Loading of Modules">
10
10
<link rel="next" href="glib-IO-Channels.html" title="IO Channels">
11
 
<meta name="generator" content="GTK-Doc V1.9 (XML mode)">
 
11
<meta name="generator" content="GTK-Doc V1.11 (XML mode)">
12
12
<link rel="stylesheet" href="style.css" type="text/css">
13
13
<link rel="chapter" href="glib.html" title="GLib Overview">
14
14
<link rel="chapter" href="glib-fundamentals.html" title="GLib Fundamentals">
26
26
<link rel="index" href="ix08.html" title="Index of new symbols in 2.12">
27
27
<link rel="index" href="ix09.html" title="Index of new symbols in 2.14">
28
28
<link rel="index" href="ix10.html" title="Index of new symbols in 2.16">
 
29
<link rel="index" href="ix11.html" title="Index of new symbols in 2.18">
29
30
</head>
30
31
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
31
32
<table class="navigation" id="top" width="100%" summary="Navigation header" cellpadding="2" cellspacing="2">
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>
38
39
</tr>
39
 
<tr><td colspan="5" class="shortcuts"><nobr><a href="#id2977424" class="shortcut">Top</a>
40
 
                  &#160;|&#160;
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>
 
42
                 | 
 
43
                <a href="#glib-Memory-Allocation.description" class="shortcut">Description</a>
 
44
</td></tr>
42
45
</table>
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>
46
49
<td valign="top">
47
 
<h2>
48
 
<a name="id2977424"></a><span class="refentrytitle">Memory Allocation</span>
49
 
</h2>
50
 
<p>Memory Allocation &#8212; 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>
51
52
</td>
52
53
<td valign="top" align="right"></td>
53
54
</tr></table></div>
54
55
<div class="refsynopsisdiv">
55
 
<h2>Synopsis</h2>
 
56
<a name="glib-Memory-Allocation.synopsis"></a><h2>Synopsis</h2>
56
57
<pre class="synopsis">
57
58
 
58
59
#include &lt;glib.h&gt;
59
60
 
60
 
 
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)
67
 
 
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);
76
 
 
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>;
79
 
 
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)
82
 
 
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);
86
 
 
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);
90
 
 
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)
 
67
 
 
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);
 
76
 
 
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>;
 
79
 
 
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)
 
82
 
 
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);
 
86
 
 
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);
 
90
 
 
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);
93
93
</pre>
94
94
</div>
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>
97
97
<p>
98
98
These functions provide support for allocating and freeing memory.
99
99
</p>
107
107
<div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
108
108
<h3 class="title">Note</h3>
109
109
<p>
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>.
115
115
</p>
116
116
</div>
117
117
</div>
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>
124
123
<p>
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>.
128
127
</p>
129
128
<p>
130
129
Since the returned pointer is already casted to the right type,
135
134
<col align="left" valign="top">
136
135
<tbody>
137
136
<tr>
138
 
<td><p><span class="term"><em class="parameter"><code>struct_type</code></em>&#160;:</span></p></td>
 
137
<td><p><span class="term"><em class="parameter"><code>struct_type</code></em> :</span></p></td>
139
138
<td>the type of the elements to allocate
140
139
</td>
141
140
</tr>
142
141
<tr>
143
 
<td><p><span class="term"><em class="parameter"><code>n_structs</code></em>&#160;:</span></p></td>
 
142
<td><p><span class="term"><em class="parameter"><code>n_structs</code></em> :</span></p></td>
144
143
<td>the number of elements to allocate
145
144
</td>
146
145
</tr>
147
146
<tr>
148
 
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span>&#160;:</span></p></td>
 
147
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
149
148
<td>a pointer to the allocated memory, cast to a pointer to <em class="parameter"><code>struct_type</code></em>
150
 
 
151
 
 
152
149
</td>
153
150
</tr>
154
151
</tbody>
156
153
</div>
157
154
<hr>
158
155
<div class="refsect2" lang="en">
159
 
<a name="id2978014"></a><h3>
160
 
<a name="g-new0"></a>g_new0()</h3>
161
 
<a class="indexterm" name="id2978027"></a><pre class="programlisting">#define             g_new0(struct_type, n_structs)</pre>
 
156
<a name="g-new0"></a><h3>g_new0()</h3>
 
157
<pre class="programlisting">#define             g_new0(struct_type, n_structs)</pre>
162
158
<p>
163
159
Allocates <em class="parameter"><code>n_structs</code></em> elements of type <em class="parameter"><code>struct_type</code></em>, initialized to 0's.
164
160
The returned pointer is cast to a pointer to the given type.
165
 
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>.
 
161
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>.
166
162
</p>
167
163
<p>
168
164
Since the returned pointer is already casted to the right type,
173
169
<col align="left" valign="top">
174
170
<tbody>
175
171
<tr>
176
 
<td><p><span class="term"><em class="parameter"><code>struct_type</code></em>&#160;:</span></p></td>
 
172
<td><p><span class="term"><em class="parameter"><code>struct_type</code></em> :</span></p></td>
177
173
<td>the type of the elements to allocate.
178
174
</td>
179
175
</tr>
180
176
<tr>
181
 
<td><p><span class="term"><em class="parameter"><code>n_structs</code></em>&#160;:</span></p></td>
 
177
<td><p><span class="term"><em class="parameter"><code>n_structs</code></em> :</span></p></td>
182
178
<td>the number of elements to allocate.
183
179
</td>
184
180
</tr>
185
181
<tr>
186
 
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span>&#160;:</span></p></td>
 
182
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
187
183
<td>a pointer to the allocated memory, cast to a pointer to <em class="parameter"><code>struct_type</code></em>.
188
 
 
189
 
 
190
184
</td>
191
185
</tr>
192
186
</tbody>
194
188
</div>
195
189
<hr>
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>
200
193
<p>
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.
204
197
</p>
205
198
<div class="variablelist"><table border="0">
206
199
<col align="left" valign="top">
207
200
<tbody>
208
201
<tr>
209
 
<td><p><span class="term"><em class="parameter"><code>struct_type</code></em>&#160;:</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
211
204
</td>
212
205
</tr>
213
206
<tr>
214
 
<td><p><span class="term"><em class="parameter"><code>mem</code></em>&#160;:</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
216
209
</td>
217
210
</tr>
218
211
<tr>
219
 
<td><p><span class="term"><em class="parameter"><code>n_structs</code></em>&#160;:</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
221
214
</td>
222
215
</tr>
223
216
<tr>
224
 
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span>&#160;:</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>
226
 
 
227
 
 
228
219
</td>
229
220
</tr>
230
221
</tbody>
232
223
</div>
233
224
<hr>
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>
238
228
<p>
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>.
243
233
</p>
244
234
<div class="variablelist"><table border="0">
245
235
<col align="left" valign="top">
246
236
<tbody>
247
237
<tr>
248
 
<td><p><span class="term"><em class="parameter"><code>struct_type</code></em>&#160;:</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
250
240
</td>
251
241
</tr>
252
242
<tr>
253
 
<td><p><span class="term"><em class="parameter"><code>n_structs</code></em>&#160;:</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
255
245
</td>
256
246
</tr>
257
247
<tr>
258
 
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span>&#160;:</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>
260
250
</td>
261
251
</tr>
262
252
</tbody>
263
253
</table></div>
264
 
<p class="since">Since 2.8
265
 
 
266
 
 
267
 
</p>
 
254
<p class="since">Since 2.8</p>
268
255
</div>
269
256
<hr>
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>
274
260
<p>
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.
280
266
</p>
281
267
<div class="variablelist"><table border="0">
282
268
<col align="left" valign="top">
283
269
<tbody>
284
270
<tr>
285
 
<td><p><span class="term"><em class="parameter"><code>struct_type</code></em>&#160;:</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
287
273
</td>
288
274
</tr>
289
275
<tr>
290
 
<td><p><span class="term"><em class="parameter"><code>n_structs</code></em>&#160;:</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
292
278
</td>
293
279
</tr>
294
280
<tr>
295
 
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span>&#160;:</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>
297
283
</td>
298
284
</tr>
299
285
</tbody>
300
286
</table></div>
301
 
<p class="since">Since 2.8
302
 
 
303
 
 
304
 
</p>
 
287
<p class="since">Since 2.8</p>
305
288
</div>
306
289
<hr>
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>
311
293
<p>
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.
316
298
</p>
317
299
<div class="variablelist"><table border="0">
318
300
<col align="left" valign="top">
319
301
<tbody>
320
302
<tr>
321
 
<td><p><span class="term"><em class="parameter"><code>struct_type</code></em>&#160;:</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
323
305
</td>
324
306
</tr>
325
307
<tr>
326
 
<td><p><span class="term"><em class="parameter"><code>mem</code></em>&#160;:</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
328
310
</td>
329
311
</tr>
330
312
<tr>
331
 
<td><p><span class="term"><em class="parameter"><code>n_structs</code></em>&#160;:</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
333
315
</td>
334
316
</tr>
335
317
<tr>
336
 
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span>&#160;:</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>
338
320
</td>
339
321
</tr>
340
322
</tbody>
341
323
</table></div>
342
 
<p class="since">Since 2.8
343
 
 
344
 
 
345
 
</p>
 
324
<p class="since">Since 2.8</p>
346
325
</div>
347
326
<hr>
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>
352
330
<p>
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>.
355
333
</p>
356
334
<div class="variablelist"><table border="0">
357
335
<col align="left" valign="top">
358
336
<tbody>
359
337
<tr>
360
 
<td><p><span class="term"><em class="parameter"><code>n_bytes</code></em>&#160;:</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
362
340
</td>
363
341
</tr>
364
342
<tr>
365
 
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span>&#160;:</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
367
 
 
368
 
 
369
345
</td>
370
346
</tr>
371
347
</tbody>
373
349
</div>
374
350
<hr>
375
351
<div class="refsect2" lang="en">
376
 
<a name="id2978753"></a><h3>
377
 
<a name="g-malloc0"></a>g_malloc0 ()</h3>
378
 
<a class="indexterm" name="id2978766"></a><pre class="programlisting"><a class="link" href="glib-Basic-Types.html#gpointer">gpointer</a>            g_malloc0                           (<a class="link" href="glib-Basic-Types.html#gsize">gsize</a> n_bytes);</pre>
 
352
<a name="g-malloc0"></a><h3>g_malloc0 ()</h3>
 
353
<pre class="programlisting"><a class="link" href="glib-Basic-Types.html#gpointer" title="gpointer">gpointer</a>            g_malloc0                           (<a class="link" href="glib-Basic-Types.html#gsize" title="gsize">gsize</a> n_bytes);</pre>
379
354
<p>
380
355
Allocates <em class="parameter"><code>n_bytes</code></em> bytes of memory, initialized to 0's.
381
 
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>.
 
356
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>.
382
357
</p>
383
358
<div class="variablelist"><table border="0">
384
359
<col align="left" valign="top">
385
360
<tbody>
386
361
<tr>
387
 
<td><p><span class="term"><em class="parameter"><code>n_bytes</code></em>&#160;:</span></p></td>
 
362
<td><p><span class="term"><em class="parameter"><code>n_bytes</code></em> :</span></p></td>
388
363
<td>the number of bytes to allocate
389
364
</td>
390
365
</tr>
391
366
<tr>
392
 
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span>&#160;:</span></p></td>
 
367
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
393
368
<td>a pointer to the allocated memory
394
 
 
395
 
 
396
369
</td>
397
370
</tr>
398
371
</tbody>
400
373
</div>
401
374
<hr>
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>
407
379
<p>
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>.
413
385
</p>
414
386
<div class="variablelist"><table border="0">
415
387
<col align="left" valign="top">
416
388
<tbody>
417
389
<tr>
418
 
<td><p><span class="term"><em class="parameter"><code>mem</code></em>&#160;:</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
420
392
</td>
421
393
</tr>
422
394
<tr>
423
 
<td><p><span class="term"><em class="parameter"><code>n_bytes</code></em>&#160;:</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
425
397
</td>
426
398
</tr>
427
399
<tr>
428
 
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span>&#160;:</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
430
 
 
431
 
 
432
402
</td>
433
403
</tr>
434
404
</tbody>
436
406
</div>
437
407
<hr>
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>
442
411
<p>
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.
445
414
</p>
446
415
<div class="variablelist"><table border="0">
447
416
<col align="left" valign="top">
448
417
<tbody>
449
418
<tr>
450
 
<td><p><span class="term"><em class="parameter"><code>n_bytes</code></em>&#160;:</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.
452
421
</td>
453
422
</tr>
454
423
<tr>
455
 
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span>&#160;:</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>.
457
 
 
458
 
 
 
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>.
459
426
</td>
460
427
</tr>
461
428
</tbody>
463
430
</div>
464
431
<hr>
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>
469
435
<p>
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.
472
438
</p>
473
439
<div class="variablelist"><table border="0">
474
440
<col align="left" valign="top">
475
441
<tbody>
476
442
<tr>
477
 
<td><p><span class="term"><em class="parameter"><code>n_bytes</code></em>&#160;:</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
479
445
</td>
480
446
</tr>
481
447
<tr>
482
 
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span>&#160;:</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>
484
450
</td>
485
451
</tr>
486
452
</tbody>
487
453
</table></div>
488
 
<p class="since">Since 2.8
489
 
 
490
 
 
491
 
</p>
 
454
<p class="since">Since 2.8</p>
492
455
</div>
493
456
<hr>
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>
499
461
<p>
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>.
503
465
</p>
504
466
<div class="variablelist"><table border="0">
505
467
<col align="left" valign="top">
506
468
<tbody>
507
469
<tr>
508
 
<td><p><span class="term"><em class="parameter"><code>mem</code></em>&#160;:</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>.
510
472
</td>
511
473
</tr>
512
474
<tr>
513
 
<td><p><span class="term"><em class="parameter"><code>n_bytes</code></em>&#160;:</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.
515
477
</td>
516
478
</tr>
517
479
<tr>
518
 
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span>&#160;:</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>.
520
 
 
521
 
 
 
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>.
522
482
</td>
523
483
</tr>
524
484
</tbody>
526
486
</div>
527
487
<hr>
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>
532
491
<p>
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.
535
494
</p>
536
495
<div class="variablelist"><table border="0">
537
496
<col align="left" valign="top">
538
497
<tbody><tr>
539
 
<td><p><span class="term"><em class="parameter"><code>mem</code></em>&#160;:</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
541
 
 
542
 
 
543
500
</td>
544
501
</tr></tbody>
545
502
</table></div>
546
503
</div>
547
504
<hr>
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;
552
508
</pre>
553
509
<p>
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>.
556
512
</p>
557
513
</div>
558
514
<hr>
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>
563
518
<p>
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>:
568
523
</p>
569
524
<div class="variablelist"><table border="0">
594
549
<tr>
595
550
<td><p><span class="term"></span></p></td>
596
551
<td><p>
597
 
    - Allocation failure due to insufficient stack space is not indicated with a <a class="link" href="glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a>
 
552
    - Allocation failure due to insufficient stack space is not indicated with a <a class="link" href="glib-Standard-Macros.html#NULL--CAPS" title="NULL"><code class="literal">NULL</code></a>
598
553
      return like e.g. with <code class="function">malloc()</code>. Instead, most systems probably handle it the same
599
554
      way as out of stack space situations from infinite function recursion, i.e.
600
555
      with a segmentation fault.
612
567
</tbody>
613
568
</table></div>
614
569
<p>
615
 
 
616
570
</p>
617
571
<div class="variablelist"><table border="0">
618
572
<col align="left" valign="top">
619
573
<tbody>
620
574
<tr>
621
 
<td><p><span class="term"><em class="parameter"><code>size</code></em>&#160;:</span></p></td>
 
575
<td><p><span class="term"><em class="parameter"><code>size</code></em> :</span></p></td>
622
576
<td>   number of bytes to allocate.
623
577
</td>
624
578
</tr>
625
579
<tr>
626
 
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span>&#160;:</span></p></td>
 
580
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
627
581
<td>space for <em class="parameter"><code>size</code></em> bytes, allocated on the stack
628
 
 
629
 
 
630
582
</td>
631
583
</tr>
632
584
</tbody>
634
586
</div>
635
587
<hr>
636
588
<div class="refsect2" lang="en">
637
 
<a name="id2979754"></a><h3>
638
 
<a name="g-newa"></a>g_newa()</h3>
639
 
<a class="indexterm" name="id2979767"></a><pre class="programlisting">#define             g_newa(struct_type, n_structs)</pre>
 
589
<a name="g-newa"></a><h3>g_newa()</h3>
 
590
<pre class="programlisting">#define             g_newa(struct_type, n_structs)</pre>
640
591
<p>
641
 
Wraps <a class="link" href="glib-Memory-Allocation.html#g-alloca"><code class="function">g_alloca()</code></a> in a more typesafe manner.
 
592
Wraps <a class="link" href="glib-Memory-Allocation.html#g-alloca" title="g_alloca()"><code class="function">g_alloca()</code></a> in a more typesafe manner.
642
593
</p>
643
594
<div class="variablelist"><table border="0">
644
595
<col align="left" valign="top">
645
596
<tbody>
646
597
<tr>
647
 
<td><p><span class="term"><em class="parameter"><code>struct_type</code></em>&#160;:</span></p></td>
 
598
<td><p><span class="term"><em class="parameter"><code>struct_type</code></em> :</span></p></td>
648
599
<td>Type of memory chunks to be allocated
649
600
</td>
650
601
</tr>
651
602
<tr>
652
 
<td><p><span class="term"><em class="parameter"><code>n_structs</code></em>&#160;:</span></p></td>
 
603
<td><p><span class="term"><em class="parameter"><code>n_structs</code></em> :</span></p></td>
653
604
<td>  Number of chunks to be allocated
654
605
</td>
655
606
</tr>
656
607
<tr>
657
 
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span>&#160;:</span></p></td>
 
608
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
658
609
<td>    Pointer to stack space for <em class="parameter"><code>n_structs</code></em> chunks of type <em class="parameter"><code>struct_type</code></em>
659
 
 
660
 
 
661
610
</td>
662
611
</tr>
663
612
</tbody>
665
614
</div>
666
615
<hr>
667
616
<div class="refsect2" lang="en">
668
 
<a name="id2979848"></a><h3>
669
 
<a name="g-memmove"></a>g_memmove()</h3>
670
 
<a class="indexterm" name="id2979860"></a><pre class="programlisting">#define             g_memmove(dest,src,len)</pre>
 
617
<a name="g-memmove"></a><h3>g_memmove()</h3>
 
618
<pre class="programlisting">#define             g_memmove(dest,src,len)</pre>
671
619
<p>
672
620
Copies a block of memory <em class="parameter"><code>len</code></em> bytes long, from <em class="parameter"><code>src</code></em> to <em class="parameter"><code>dest</code></em>.
673
621
The source and destination areas may overlap.
678
626
typically simply resolve to <code class="function">memmove()</code> and GLib does not include 
679
627
<code class="filename">string.h</code> for you.</p>
680
628
<p>
681
 
 
682
629
</p>
683
630
<div class="variablelist"><table border="0">
684
631
<col align="left" valign="top">
685
632
<tbody>
686
633
<tr>
687
 
<td><p><span class="term"><em class="parameter"><code>dest</code></em>&#160;:</span></p></td>
 
634
<td><p><span class="term"><em class="parameter"><code>dest</code></em> :</span></p></td>
688
635
<td> the destination address to copy the bytes to.
689
636
</td>
690
637
</tr>
691
638
<tr>
692
 
<td><p><span class="term"><em class="parameter"><code>src</code></em>&#160;:</span></p></td>
 
639
<td><p><span class="term"><em class="parameter"><code>src</code></em> :</span></p></td>
693
640
<td> the source address to copy the bytes from.
694
641
</td>
695
642
</tr>
696
643
<tr>
697
 
<td><p><span class="term"><em class="parameter"><code>len</code></em>&#160;:</span></p></td>
 
644
<td><p><span class="term"><em class="parameter"><code>len</code></em> :</span></p></td>
698
645
<td> the number of bytes to copy.
699
646
</td>
700
647
</tr>
703
650
</div>
704
651
<hr>
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>
710
656
<p>
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>.
713
659
</p>
714
660
<div class="variablelist"><table border="0">
715
661
<col align="left" valign="top">
716
662
<tbody>
717
663
<tr>
718
 
<td><p><span class="term"><em class="parameter"><code>mem</code></em>&#160;:</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.
720
666
</td>
721
667
</tr>
722
668
<tr>
723
 
<td><p><span class="term"><em class="parameter"><code>byte_size</code></em>&#160;:</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.
725
671
</td>
726
672
</tr>
727
673
<tr>
728
 
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span>&#160;:</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>.
731
 
 
732
 
 
 
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>.
733
677
</td>
734
678
</tr>
735
679
</tbody>
737
681
</div>
738
682
<hr>
739
683
<div class="refsect2" lang="en">
740
 
<a name="id2980136"></a><h3>
741
 
<a name="GMemVTable"></a>GMemVTable</h3>
742
 
<a class="indexterm" name="id2980148"></a><pre class="programlisting">typedef struct {
 
684
<a name="GMemVTable"></a><h3>GMemVTable</h3>
 
685
<pre class="programlisting">typedef struct {
743
686
  gpointer (*malloc)      (gsize    n_bytes);
744
687
  gpointer (*realloc)     (gpointer mem,
745
688
                           gsize    n_bytes);
753
696
} GMemVTable;
754
697
</pre>
755
698
<p>
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.
759
702
</p>
760
703
<div class="variablelist"><table border="0">
761
704
<col align="left" valign="top">
762
705
<tbody>
763
706
<tr>
764
 
<td><p><span class="term"><em class="structfield"><code>malloc</code></em>&#160;()</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.
766
709
</td>
767
710
</tr>
768
711
<tr>
769
 
<td><p><span class="term"><em class="structfield"><code>realloc</code></em>&#160;()</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.
771
714
</td>
772
715
</tr>
773
716
<tr>
774
 
<td><p><span class="term"><em class="structfield"><code>free</code></em>&#160;()</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.
776
719
</td>
777
720
</tr>
778
721
<tr>
779
 
<td><p><span class="term"><em class="structfield"><code>calloc</code></em>&#160;()</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.
781
724
</td>
782
725
</tr>
783
726
<tr>
784
 
<td><p><span class="term"><em class="structfield"><code>try_malloc</code></em>&#160;()</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.
786
729
</td>
787
730
</tr>
788
731
<tr>
789
 
<td><p><span class="term"><em class="structfield"><code>try_realloc</code></em>&#160;()</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.
791
 
 
792
734
</td>
793
735
</tr>
794
736
</tbody>
796
738
</div>
797
739
<hr>
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>
802
743
<p>
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.
810
751
</p>
811
752
<div class="variablelist"><table border="0">
812
753
<col align="left" valign="top">
813
754
<tbody><tr>
814
 
<td><p><span class="term"><em class="parameter"><code>vtable</code></em>&#160;:</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.
816
 
 
817
 
 
818
757
</td>
819
758
</tr></tbody>
820
759
</table></div>
821
760
</div>
822
761
<hr>
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>
827
765
<p>
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.
833
771
</p>
834
772
<p>
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>
836
774
<p>
837
 
 
838
775
</p>
839
776
<div class="variablelist"><table border="0">
840
777
<col align="left" valign="top">
841
778
<tbody><tr>
842
 
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span>&#160;:</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.
844
781
</td>
845
782
</tr></tbody>
846
783
</table></div>
847
784
</div>
848
785
<hr>
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;
853
789
</pre>
854
790
<p>
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
858
794
of your program.
859
795
</p>
860
796
</div>
861
797
<hr>
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>
866
801
<p>
867
802
Outputs a summary of memory usage.
868
803
</p>
875
810
</p>
876
811
<p>
877
812
Note that this function will not output anything unless you have
878
 
previously installed the <a class="link" href="glib-Memory-Allocation.html#glib-mem-profiler-table"><span class="type">glib_mem_profiler_table</span></a> with <a class="link" href="glib-Memory-Allocation.html#g-mem-set-vtable"><code class="function">g_mem_set_vtable()</code></a>.
 
813
previously installed the <a class="link" href="glib-Memory-Allocation.html#glib-mem-profiler-table" title="glib_mem_profiler_table"><span class="type">glib_mem_profiler_table</span></a> with <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>.
879
814
</p>
880
815
</div>
881
816
</div>
882
 
<div class="refsect1" lang="en">
883
 
<a name="id2980695"></a><div class="refsect2" lang="en"><a name="id2980696"></a></div>
 
817
</div>
 
818
<div class="footer">
884
819
<hr>
885
 
<div class="refsect2" lang="en"><a name="id2980697"></a></div>
886
 
</div>
887
 
</div>
 
820
          Generated by GTK-Doc V1.11</div>
888
821
</body>
889
822
</html>