36
37
<th width="100%" align="center">GLib Reference Manual</th>
37
38
<td><a accesskey="n" href="tools.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="#id3426144" class="shortcut">Top</a>
41
<a href="#id3426218" class="shortcut">Description</a></nobr></td></tr>
40
<tr><td colspan="5" class="shortcuts">
41
<a href="#glib-Memory-Allocators.synopsis" class="shortcut">Top</a>
43
<a href="#glib-Memory-Allocators.description" class="shortcut">Description</a>
43
46
<div class="refentry" lang="en">
44
47
<a name="glib-Memory-Allocators"></a><div class="titlepage"></div>
45
48
<div class="refnamediv"><table width="100%"><tr>
48
<a name="id3426144"></a><span class="refentrytitle">Memory Allocators</span>
50
<p>Memory Allocators — deprecated way to allocate chunks of memory for GList, GSList and GNode</p>
50
<h2><span class="refentrytitle"><a name="glib-Memory-Allocators.top_of_page"></a>Memory Allocators</span></h2>
51
<p>Memory Allocators — deprecated way to allocate chunks of memory for GList, GSList and GNode</p>
52
53
<td valign="top" align="right"></td>
53
54
</tr></table></div>
54
55
<div class="refsynopsisdiv">
56
<a name="glib-Memory-Allocators.synopsis"></a><h2>Synopsis</h2>
56
57
<pre class="synopsis">
58
59
#include <glib.h>
61
<a class="link" href="glib-Memory-Allocators.html#GAllocator">GAllocator</a>;
62
<a class="link" href="glib-Memory-Allocators.html#GAllocator">GAllocator</a>* <a class="link" href="glib-Memory-Allocators.html#g-allocator-new">g_allocator_new</a> (const <a class="link" href="glib-Basic-Types.html#gchar">gchar</a> *name,
63
<a class="link" href="glib-Basic-Types.html#guint">guint</a> n_preallocs);
64
void <a class="link" href="glib-Memory-Allocators.html#g-allocator-free">g_allocator_free</a> (<a class="link" href="glib-Memory-Allocators.html#GAllocator">GAllocator</a> *allocator);
61
<a class="link" href="glib-Memory-Allocators.html#GAllocator" title="GAllocator">GAllocator</a>;
62
<a class="link" href="glib-Memory-Allocators.html#GAllocator" title="GAllocator">GAllocator</a>* <a class="link" href="glib-Memory-Allocators.html#g-allocator-new" title="g_allocator_new ()">g_allocator_new</a> (const <a class="link" href="glib-Basic-Types.html#gchar" title="gchar">gchar</a> *name,
63
<a class="link" href="glib-Basic-Types.html#guint" title="guint">guint</a> n_preallocs);
64
void <a class="link" href="glib-Memory-Allocators.html#g-allocator-free" title="g_allocator_free ()">g_allocator_free</a> (<a class="link" href="glib-Memory-Allocators.html#GAllocator" title="GAllocator">GAllocator</a> *allocator);
68
67
<div class="refsect1" lang="en">
69
<a name="id3426218"></a><h2>Description</h2>
68
<a name="glib-Memory-Allocators.description"></a><h2>Description</h2>
73
Prior to 2.10, <a class="link" href="glib-Memory-Allocators.html#GAllocator"><span class="type">GAllocator</span></a> was used as an efficient way to allocate
74
small pieces of memory for use with the <a class="link" href="glib-Doubly-Linked-Lists.html#GList"><span class="type">GList</span></a>, <a class="link" href="glib-Singly-Linked-Lists.html#GSList"><span class="type">GSList</span></a> and <a class="link" href="glib-N-ary-Trees.html#GNode"><span class="type">GNode</span></a> data
75
structures. Since 2.10, it has been completely replaced by the
72
Prior to 2.10, <a class="link" href="glib-Memory-Allocators.html#GAllocator" title="GAllocator"><span class="type">GAllocator</span></a> was used as an efficient way to allocate
73
small pieces of memory for use with the <a class="link" href="glib-Doubly-Linked-Lists.html#GList" title="GList"><span class="type">GList</span></a>, <a class="link" href="glib-Singly-Linked-Lists.html#GSList" title="GSList"><span class="type">GSList</span></a> and <a class="link" href="glib-N-ary-Trees.html#GNode" title="GNode"><span class="type">GNode</span></a> data
74
structures. Since 2.10, it has been completely replaced by the
76
75
<a class="link" href="glib-Memory-Slices.html" title="Memory Slices">slice allocator</a> and deprecated.
79
78
<div class="refsect1" lang="en">
80
<a name="id3426277"></a><h2>Details</h2>
79
<a name="glib-Memory-Allocators.details"></a><h2>Details</h2>
81
80
<div class="refsect2" lang="en">
82
<a name="id3426287"></a><h3>
83
<a name="GAllocator"></a>GAllocator</h3>
84
<a class="indexterm" name="id3426302"></a><pre class="programlisting">typedef struct _GAllocator GAllocator;</pre>
81
<a name="GAllocator"></a><h3>GAllocator</h3>
82
<pre class="programlisting">typedef struct _GAllocator GAllocator;</pre>
85
83
<div class="warning" style="margin-left: 0.5in; margin-right: 0.5in;">
86
84
<h3 class="title">Warning</h3>
87
85
<p><code class="literal">GAllocator</code> is deprecated and should not be used in newly-written code.</p>
90
The <span class="structname">GAllocator</span> struct contains private data. and
88
The <span class="structname">GAllocator</span> struct contains private data. and
91
89
should only be accessed using the following functions.
95
93
<div class="refsect2" lang="en">
96
<a name="id3426335"></a><h3>
97
<a name="g-allocator-new"></a>g_allocator_new ()</h3>
98
<a class="indexterm" name="id3426350"></a><pre class="programlisting"><a class="link" href="glib-Memory-Allocators.html#GAllocator">GAllocator</a>* g_allocator_new (const <a class="link" href="glib-Basic-Types.html#gchar">gchar</a> *name,
99
<a class="link" href="glib-Basic-Types.html#guint">guint</a> n_preallocs);</pre>
94
<a name="g-allocator-new"></a><h3>g_allocator_new ()</h3>
95
<pre class="programlisting"><a class="link" href="glib-Memory-Allocators.html#GAllocator" title="GAllocator">GAllocator</a>* g_allocator_new (const <a class="link" href="glib-Basic-Types.html#gchar" title="gchar">gchar</a> *name,
96
<a class="link" href="glib-Basic-Types.html#guint" title="guint">guint</a> n_preallocs);</pre>
100
97
<div class="warning" style="margin-left: 0.5in; margin-right: 0.5in;">
101
98
<h3 class="title">Warning</h3>
102
99
<p><code class="literal">g_allocator_new</code> has been deprecated since version 2.10 and should not be used in newly-written code. Use the <a class="link" href="glib-Memory-Slices.html" title="Memory Slices">slice allocator</a>
106
Creates a new <a class="link" href="glib-Memory-Allocators.html#GAllocator"><span class="type">GAllocator</span></a>.
103
Creates a new <a class="link" href="glib-Memory-Allocators.html#GAllocator" title="GAllocator"><span class="type">GAllocator</span></a>.
108
105
<div class="variablelist"><table border="0">
109
106
<col align="left" valign="top">
112
<td><p><span class="term"><em class="parameter"><code>name</code></em> :</span></p></td>
113
<td>the name of the <a class="link" href="glib-Memory-Allocators.html#GAllocator"><span class="type">GAllocator</span></a>. This name is used to set the name of the
114
<a class="link" href="glib-Memory-Chunks.html#GMemChunk"><span class="type">GMemChunk</span></a> used by the <a class="link" href="glib-Memory-Allocators.html#GAllocator"><span class="type">GAllocator</span></a>, and is only used for debugging.
109
<td><p><span class="term"><em class="parameter"><code>name</code></em> :</span></p></td>
110
<td>the name of the <a class="link" href="glib-Memory-Allocators.html#GAllocator" title="GAllocator"><span class="type">GAllocator</span></a>. This name is used to set the name of the
111
<a class="link" href="glib-Memory-Chunks.html#GMemChunk" title="GMemChunk"><span class="type">GMemChunk</span></a> used by the <a class="link" href="glib-Memory-Allocators.html#GAllocator" title="GAllocator"><span class="type">GAllocator</span></a>, and is only used for debugging.
118
<td><p><span class="term"><em class="parameter"><code>n_preallocs</code></em> :</span></p></td>
115
<td><p><span class="term"><em class="parameter"><code>n_preallocs</code></em> :</span></p></td>
119
116
<td>the number of elements in each block of memory allocated.
120
Larger blocks mean less calls to <a class="link" href="glib-Memory-Allocation.html#g-malloc"><code class="function">g_malloc()</code></a>, but some memory may be wasted.
117
Larger blocks mean less calls to <a class="link" href="glib-Memory-Allocation.html#g-malloc" title="g_malloc ()"><code class="function">g_malloc()</code></a>, but some memory may be wasted.
121
118
(GLib uses 128 elements per block by default.) The value must be between 1
126
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
127
<td>a new <a class="link" href="glib-Memory-Allocators.html#GAllocator"><span class="type">GAllocator</span></a>.
123
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
124
<td>a new <a class="link" href="glib-Memory-Allocators.html#GAllocator" title="GAllocator"><span class="type">GAllocator</span></a>.
134
131
<div class="refsect2" lang="en">
135
<a name="id3426503"></a><h3>
136
<a name="g-allocator-free"></a>g_allocator_free ()</h3>
137
<a class="indexterm" name="id3426518"></a><pre class="programlisting">void g_allocator_free (<a class="link" href="glib-Memory-Allocators.html#GAllocator">GAllocator</a> *allocator);</pre>
132
<a name="g-allocator-free"></a><h3>g_allocator_free ()</h3>
133
<pre class="programlisting">void g_allocator_free (<a class="link" href="glib-Memory-Allocators.html#GAllocator" title="GAllocator">GAllocator</a> *allocator);</pre>
138
134
<div class="warning" style="margin-left: 0.5in; margin-right: 0.5in;">
139
135
<h3 class="title">Warning</h3>
140
136
<p><code class="literal">g_allocator_free</code> has been deprecated since version 2.10 and should not be used in newly-written code. Use the <a class="link" href="glib-Memory-Slices.html" title="Memory Slices">slice allocator</a>
144
Frees all of the memory allocated by the <a class="link" href="glib-Memory-Allocators.html#GAllocator"><span class="type">GAllocator</span></a>.
140
Frees all of the memory allocated by the <a class="link" href="glib-Memory-Allocators.html#GAllocator" title="GAllocator"><span class="type">GAllocator</span></a>.
146
142
<div class="variablelist"><table border="0">
147
143
<col align="left" valign="top">
149
<td><p><span class="term"><em class="parameter"><code>allocator</code></em> :</span></p></td>
150
<td>a <a class="link" href="glib-Memory-Allocators.html#GAllocator"><span class="type">GAllocator</span></a>.
145
<td><p><span class="term"><em class="parameter"><code>allocator</code></em> :</span></p></td>
146
<td>a <a class="link" href="glib-Memory-Allocators.html#GAllocator" title="GAllocator"><span class="type">GAllocator</span></a>.
156
<div class="refsect1" lang="en">
157
<a name="id3426602"></a><div class="refsect2" lang="en"><a name="id3426604"></a></div>
159
<div class="refsect2" lang="en"><a name="id3426605"></a></div>
155
Generated by GTK-Doc V1.11</div>