~ubuntu-branches/ubuntu/utopic/glib2.0/utopic

« back to all changes in this revision

Viewing changes to docs/reference/glib/xml/memory_chunks.xml

Tags: upstream-2.12.12
ImportĀ upstreamĀ versionĀ 2.12.12

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<refentry id="glib-Memory-Chunks">
 
2
<refmeta>
 
3
<refentrytitle role="top_of_page">Memory Chunks</refentrytitle>
 
4
<manvolnum>3</manvolnum>
 
5
<refmiscinfo>GLIB Library</refmiscinfo>
 
6
</refmeta>
 
7
 
 
8
<refnamediv>
 
9
<refname>Memory Chunks</refname>
 
10
<refpurpose>deprecated way to allocate groups of equal-sized chunks of memory.</refpurpose>
 
11
<!--[<xref linkend="desc" endterm="desc.title"/>]-->
 
12
</refnamediv>
 
13
 
 
14
<refsynopsisdiv role="synopsis">
 
15
<title role="synopsis.title">Synopsis</title>
 
16
 
 
17
<synopsis>
 
18
 
 
19
#include &lt;glib.h&gt;
 
20
 
 
21
 
 
22
                    <link linkend="GMemChunk">GMemChunk</link>;
 
23
#define             <link linkend="G-ALLOC-AND-FREE:CAPS">G_ALLOC_AND_FREE</link>
 
24
#define             <link linkend="G-ALLOC-ONLY:CAPS">G_ALLOC_ONLY</link>
 
25
 
 
26
<link linkend="GMemChunk">GMemChunk</link>*          <link linkend="g-mem-chunk-new">g_mem_chunk_new</link>                     (const <link linkend="gchar">gchar</link> *name,
 
27
                                                         <link linkend="gint">gint</link> atom_size,
 
28
                                                         <link linkend="gulong">gulong</link> area_size,
 
29
                                                         <link linkend="gint">gint</link> type);
 
30
<link linkend="gpointer">gpointer</link>            <link linkend="g-mem-chunk-alloc">g_mem_chunk_alloc</link>                   (<link linkend="GMemChunk">GMemChunk</link> *mem_chunk);
 
31
<link linkend="gpointer">gpointer</link>            <link linkend="g-mem-chunk-alloc0">g_mem_chunk_alloc0</link>                  (<link linkend="GMemChunk">GMemChunk</link> *mem_chunk);
 
32
<link linkend="void">void</link>                <link linkend="g-mem-chunk-free">g_mem_chunk_free</link>                    (<link linkend="GMemChunk">GMemChunk</link> *mem_chunk,
 
33
                                                         <link linkend="gpointer">gpointer</link> mem);
 
34
<link linkend="void">void</link>                <link linkend="g-mem-chunk-destroy">g_mem_chunk_destroy</link>                 (<link linkend="GMemChunk">GMemChunk</link> *mem_chunk);
 
35
 
 
36
#define             <link linkend="g-mem-chunk-create">g_mem_chunk_create</link>                  (type, pre_alloc, alloc_type)
 
37
#define             <link linkend="g-chunk-new">g_chunk_new</link>                         (type, chunk)
 
38
#define             <link linkend="g-chunk-new0">g_chunk_new0</link>                        (type, chunk)
 
39
#define             <link linkend="g-chunk-free">g_chunk_free</link>                        (mem, mem_chunk)
 
40
 
 
41
<link linkend="void">void</link>                <link linkend="g-mem-chunk-reset">g_mem_chunk_reset</link>                   (<link linkend="GMemChunk">GMemChunk</link> *mem_chunk);
 
42
<link linkend="void">void</link>                <link linkend="g-mem-chunk-clean">g_mem_chunk_clean</link>                   (<link linkend="GMemChunk">GMemChunk</link> *mem_chunk);
 
43
<link linkend="void">void</link>                <link linkend="g-blow-chunks">g_blow_chunks</link>                       (void);
 
44
 
 
45
<link linkend="void">void</link>                <link linkend="g-mem-chunk-info">g_mem_chunk_info</link>                    (void);
 
46
<link linkend="void">void</link>                <link linkend="g-mem-chunk-print">g_mem_chunk_print</link>                   (<link linkend="GMemChunk">GMemChunk</link> *mem_chunk);
 
47
</synopsis>
 
48
</refsynopsisdiv>
 
49
 
 
50
 
 
51
 
 
52
 
 
53
 
 
54
 
 
55
 
 
56
 
 
57
 
 
58
<refsect1 role="desc">
 
59
<title role="desc.title">Description</title>
 
60
<para>
 
61
Memory chunks provide an space-efficient way to allocate equal-sized 
 
62
pieces of memory, called atoms. However, due to the administrative 
 
63
overhead (in particular for <link linkend="G-ALLOC-AND-FREE:CAPS"><type>G_ALLOC_AND_FREE</type></link>, and when used from multiple 
 
64
threads), they are in practise often slower than direct use of <link linkend="g-malloc"><function>g_malloc()</function></link>.
 
65
Therefore, memory chunks have been deprecated in favor of the 
 
66
<link linkend="glib-Memory-Slices">slice allocator</link>,
 
67
which has been added in 2.10. All internal uses of memory chunks in
 
68
GLib have been converted to the <literal>g_slice</literal> API.
 
69
</para>
 
70
<para>
 
71
There are two types of memory chunks, <link linkend="G-ALLOC-ONLY:CAPS"><type>G_ALLOC_ONLY</type></link>, and <link linkend="G-ALLOC-AND-FREE:CAPS"><type>G_ALLOC_AND_FREE</type></link>.
 
72
<itemizedlist>
 
73
<listitem><para>
 
74
<link linkend="G-ALLOC-ONLY:CAPS"><type>G_ALLOC_ONLY</type></link> chunks only allow allocation of atoms. The atoms can never
 
75
be freed individually. The memory chunk can only be free in its entirety.
 
76
</para></listitem>
 
77
<listitem><para>
 
78
<link linkend="G-ALLOC-AND-FREE:CAPS"><type>G_ALLOC_AND_FREE</type></link> chunks do allow atoms to be freed individually.
 
79
The disadvantage of this is that the memory chunk has to keep track of which
 
80
atoms have been freed. This results in more memory being used and a slight
 
81
degradation in performance.
 
82
</para></listitem>
 
83
 
 
84
</itemizedlist>
 
85
</para>
 
86
<para>
 
87
To create a memory chunk use <link linkend="g-mem-chunk-new"><function>g_mem_chunk_new()</function></link> or the convenience macro
 
88
<link linkend="g-mem-chunk-create"><function>g_mem_chunk_create()</function></link>.
 
89
</para>
 
90
<para>
 
91
To allocate a new atom use <link linkend="g-mem-chunk-alloc"><function>g_mem_chunk_alloc()</function></link>, <link linkend="g-mem-chunk-alloc0"><function>g_mem_chunk_alloc0()</function></link>,
 
92
or the convenience macros <link linkend="g-chunk-new"><function>g_chunk_new()</function></link> or <link linkend="g-chunk-new0"><function>g_chunk_new0()</function></link>. 
 
93
</para>
 
94
<para>
 
95
To free an atom use <link linkend="g-mem-chunk-free"><function>g_mem_chunk_free()</function></link>, or the convenience macro
 
96
<link linkend="g-chunk-free"><function>g_chunk_free()</function></link>. (Atoms can only be freed if the memory chunk is created
 
97
with the type set to <link linkend="G-ALLOC-AND-FREE:CAPS"><type>G_ALLOC_AND_FREE</type></link>.)
 
98
</para>
 
99
<para>
 
100
To free any blocks of memory which are no longer being used, use
 
101
<link linkend="g-mem-chunk-clean"><function>g_mem_chunk_clean()</function></link>. To clean all memory chunks, use <link linkend="g-blow-chunks"><function>g_blow_chunks()</function></link>.
 
102
</para>
 
103
<para>
 
104
To reset the memory chunk, freeing all of the atoms, use <link linkend="g-mem-chunk-reset"><function>g_mem_chunk_reset()</function></link>.
 
105
</para>
 
106
<para>
 
107
To destroy a memory chunk, use <link linkend="g-mem-chunk-destroy"><function>g_mem_chunk_destroy()</function></link>.
 
108
</para>
 
109
<para>
 
110
To help debug memory chunks, use <link linkend="g-mem-chunk-info"><function>g_mem_chunk_info()</function></link> and <link linkend="g-mem-chunk-print"><function>g_mem_chunk_print()</function></link>.
 
111
</para>
 
112
 
 
113
<example>
 
114
<title>Using a <structname>GMemChunk</structname></title>
 
115
<programlisting>
 
116
  GMemChunk *mem_chunk;
 
117
  gchar *mem[10000];
 
118
  gint i;
 
119
 
 
120
  /* Create a GMemChunk with atoms 50 bytes long, and memory blocks holding
 
121
     100 bytes. Note that this means that only 2 atoms fit into each memory
 
122
     block and so isn't very efficient. */
 
123
  mem_chunk = g_mem_chunk_new ("test mem chunk", 50, 100, G_ALLOC_AND_FREE);
 
124
 
 
125
  /* Now allocate 10000 atoms. */
 
126
  for (i = 0; i &lt; 10000; i++)
 
127
    {
 
128
      mem[i] = g_chunk_new (gchar, mem_chunk);
 
129
 
 
130
      /* Fill in the atom memory with some junk. */
 
131
      for (j = 0; j &lt; 50; j++)
 
132
        mem[i][j] = i * j;
 
133
    }
 
134
 
 
135
  /* Now free all of the atoms. Note that since we are going to destroy the
 
136
     GMemChunk, this wouldn't normally be used. */
 
137
  for (i = 0; i &lt; 10000; i++)
 
138
    {
 
139
      g_mem_chunk_free (mem_chunk, mem[i]);
 
140
    }
 
141
 
 
142
  /* We are finished with the GMemChunk, so we destroy it. */
 
143
  g_mem_chunk_destroy (mem_chunk);
 
144
</programlisting></example>
 
145
 
 
146
<example>
 
147
<title>Using a <structname>GMemChunk</structname> with data structures</title>
 
148
<programlisting>
 
149
  GMemChunk *array_mem_chunk;
 
150
  GRealArray *array;
 
151
 
 
152
  /* Create a GMemChunk to hold GRealArray structures, using the
 
153
     g_mem_chunk_create(<!-- -->) convenience macro. We want 1024 atoms in each
 
154
     memory block, and we want to be able to free individual atoms. */
 
155
  array_mem_chunk = g_mem_chunk_create (GRealArray, 1024, G_ALLOC_AND_FREE);
 
156
 
 
157
  /* Allocate one atom, using the g_chunk_new(<!-- -->) convenience macro. */
 
158
  array = g_chunk_new (GRealArray, array_mem_chunk);
 
159
 
 
160
  /* We can now use array just like a normal pointer to a structure. */
 
161
  array->data            = NULL;
 
162
  array->len             = 0;
 
163
  array->alloc           = 0;
 
164
  array->zero_terminated = (zero_terminated ? 1 : 0);
 
165
  array->clear           = (clear ? 1 : 0);
 
166
  array->elt_size        = elt_size;
 
167
 
 
168
  /* We can free the element, so it can be reused. */
 
169
  g_chunk_free (array, array_mem_chunk);
 
170
 
 
171
  /* We destroy the GMemChunk when we are finished with it. */
 
172
  g_mem_chunk_destroy (array_mem_chunk);
 
173
</programlisting></example>
 
174
</refsect1>
 
175
 
 
176
<refsect1 role="details">
 
177
<title role="details.title">Details</title>
 
178
<refsect2>
 
179
<title><anchor id="GMemChunk" role="struct" condition="deprecated:"/>GMemChunk</title>
 
180
<indexterm role="deprecated"><primary>GMemChunk</primary></indexterm><programlisting>typedef struct _GMemChunk GMemChunk;</programlisting>
 
181
<warning><para><literal>GMemChunk</literal> is deprecated and should not be used in newly-written code.</para></warning>
 
182
<para>
 
183
The <link linkend="GMemChunk"><type>GMemChunk</type></link> struct is an opaque data structure representing a memory
 
184
chunk. It should be accessed only through the use of the following functions.
 
185
</para></refsect2>
 
186
<refsect2>
 
187
<title><anchor id="G-ALLOC-AND-FREE:CAPS" role="macro" condition="deprecated:"/>G_ALLOC_AND_FREE</title>
 
188
<indexterm role="deprecated"><primary>G_ALLOC_AND_FREE</primary></indexterm><programlisting>#define G_ALLOC_AND_FREE  2
 
189
</programlisting>
 
190
<warning><para><literal>G_ALLOC_AND_FREE</literal> is deprecated and should not be used in newly-written code.</para></warning>
 
191
<para>
 
192
Specifies the type of a <link linkend="GMemChunk"><type>GMemChunk</type></link>.
 
193
Used in <link linkend="g-mem-chunk-new"><function>g_mem_chunk_new()</function></link> and <link linkend="g-mem-chunk-create"><function>g_mem_chunk_create()</function></link> to specify that atoms
 
194
will be freed individually.
 
195
</para></refsect2>
 
196
<refsect2>
 
197
<title><anchor id="G-ALLOC-ONLY:CAPS" role="macro" condition="deprecated:"/>G_ALLOC_ONLY</title>
 
198
<indexterm role="deprecated"><primary>G_ALLOC_ONLY</primary></indexterm><programlisting>#define G_ALLOC_ONLY      1
 
199
</programlisting>
 
200
<warning><para><literal>G_ALLOC_ONLY</literal> is deprecated and should not be used in newly-written code.</para></warning>
 
201
<para>
 
202
Specifies the type of a <link linkend="GMemChunk"><type>GMemChunk</type></link>.
 
203
Used in <link linkend="g-mem-chunk-new"><function>g_mem_chunk_new()</function></link> and <link linkend="g-mem-chunk-create"><function>g_mem_chunk_create()</function></link> to specify that atoms
 
204
will never be freed individually.
 
205
</para></refsect2>
 
206
<refsect2>
 
207
<title><anchor id="g-mem-chunk-new" role="function" condition="deprecated"/>g_mem_chunk_new ()</title>
 
208
<indexterm role="deprecated"><primary>g_mem_chunk_new</primary></indexterm><programlisting><link linkend="GMemChunk">GMemChunk</link>*          g_mem_chunk_new                     (const <link linkend="gchar">gchar</link> *name,
 
209
                                                         <link linkend="gint">gint</link> atom_size,
 
210
                                                         <link linkend="gulong">gulong</link> area_size,
 
211
                                                         <link linkend="gint">gint</link> type);</programlisting>
 
212
<warning><para><literal>g_mem_chunk_new</literal> has been deprecated since version 2.10 and should not be used in newly-written code. Use the <link linkend="glib-Memory-Slices">slice allocator</link>
 
213
  instead</para></warning>
 
214
<para>
 
215
Creates a new <link linkend="GMemChunk"><type>GMemChunk</type></link>.
 
216
</para><variablelist role="params">
 
217
<varlistentry><term><parameter>name</parameter>&nbsp;:</term>
 
218
<listitem><simpara>a string to identify the <link linkend="GMemChunk"><type>GMemChunk</type></link>. It is not copied so it
 
219
should be valid for the lifetime of the <link linkend="GMemChunk"><type>GMemChunk</type></link>. It is only used in
 
220
<link linkend="g-mem-chunk-print"><function>g_mem_chunk_print()</function></link>, which is used for debugging.
 
221
</simpara></listitem></varlistentry>
 
222
<varlistentry><term><parameter>atom_size</parameter>&nbsp;:</term>
 
223
<listitem><simpara>the size, in bytes, of each element in the <link linkend="GMemChunk"><type>GMemChunk</type></link>.
 
224
</simpara></listitem></varlistentry>
 
225
<varlistentry><term><parameter>area_size</parameter>&nbsp;:</term>
 
226
<listitem><simpara>the size, in bytes, of each block of memory allocated to contain
 
227
the atoms.
 
228
</simpara></listitem></varlistentry>
 
229
<varlistentry><term><parameter>type</parameter>&nbsp;:</term>
 
230
<listitem><simpara>the type of the <link linkend="GMemChunk"><type>GMemChunk</type></link>.
 
231
<link linkend="G-ALLOC-AND-FREE:CAPS"><type>G_ALLOC_AND_FREE</type></link> is used if the atoms will be freed individually.
 
232
<link linkend="G-ALLOC-ONLY:CAPS"><type>G_ALLOC_ONLY</type></link> should be used if atoms will never be freed individually.
 
233
<link linkend="G-ALLOC-ONLY:CAPS"><type>G_ALLOC_ONLY</type></link> is quicker, since it does not need to track free atoms,
 
234
but it obviously wastes memory if you no longer need many of the atoms.
 
235
</simpara></listitem></varlistentry>
 
236
<varlistentry><term><emphasis>Returns</emphasis>&nbsp;:</term><listitem><simpara>the new <link linkend="GMemChunk"><type>GMemChunk</type></link>.
 
237
</simpara></listitem></varlistentry>
 
238
</variablelist></refsect2>
 
239
<refsect2>
 
240
<title><anchor id="g-mem-chunk-alloc" role="function" condition="deprecated:2.10: Use g_slice_alloc() instead"/>g_mem_chunk_alloc ()</title>
 
241
<indexterm role="deprecated"><primary>g_mem_chunk_alloc</primary></indexterm><programlisting><link linkend="gpointer">gpointer</link>            g_mem_chunk_alloc                   (<link linkend="GMemChunk">GMemChunk</link> *mem_chunk);</programlisting>
 
242
<warning><para><literal>g_mem_chunk_alloc</literal> has been deprecated since version 2.10 and should not be used in newly-written code. Use <link linkend="g-slice-alloc"><function>g_slice_alloc()</function></link> instead</para></warning>
 
243
<para>
 
244
Allocates an atom of memory from a <link linkend="GMemChunk"><type>GMemChunk</type></link>.
 
245
</para><variablelist role="params">
 
246
<varlistentry><term><parameter>mem_chunk</parameter>&nbsp;:</term>
 
247
<listitem><simpara>a <link linkend="GMemChunk"><type>GMemChunk</type></link>.
 
248
</simpara></listitem></varlistentry>
 
249
<varlistentry><term><emphasis>Returns</emphasis>&nbsp;:</term><listitem><simpara>a pointer to the allocated atom.
 
250
</simpara></listitem></varlistentry>
 
251
</variablelist></refsect2>
 
252
<refsect2>
 
253
<title><anchor id="g-mem-chunk-alloc0" role="function" condition="deprecated:2.10:  Use g_slice_alloc0() instead"/>g_mem_chunk_alloc0 ()</title>
 
254
<indexterm role="deprecated"><primary>g_mem_chunk_alloc0</primary></indexterm><programlisting><link linkend="gpointer">gpointer</link>            g_mem_chunk_alloc0                  (<link linkend="GMemChunk">GMemChunk</link> *mem_chunk);</programlisting>
 
255
<warning><para><literal>g_mem_chunk_alloc0</literal> has been deprecated since version 2.10 and should not be used in newly-written code. Use <link linkend="g-slice-alloc0"><function>g_slice_alloc0()</function></link> instead</para></warning>
 
256
<para>
 
257
Allocates an atom of memory from a <link linkend="GMemChunk"><type>GMemChunk</type></link>, setting the memory to 0.
 
258
</para><variablelist role="params">
 
259
<varlistentry><term><parameter>mem_chunk</parameter>&nbsp;:</term>
 
260
<listitem><simpara>a <link linkend="GMemChunk"><type>GMemChunk</type></link>.
 
261
</simpara></listitem></varlistentry>
 
262
<varlistentry><term><emphasis>Returns</emphasis>&nbsp;:</term><listitem><simpara>a pointer to the allocated atom.
 
263
</simpara></listitem></varlistentry>
 
264
</variablelist></refsect2>
 
265
<refsect2>
 
266
<title><anchor id="g-mem-chunk-free" role="function" condition="deprecated:2.10: Use g_slice_free1() instead"/>g_mem_chunk_free ()</title>
 
267
<indexterm role="deprecated"><primary>g_mem_chunk_free</primary></indexterm><programlisting><link linkend="void">void</link>                g_mem_chunk_free                    (<link linkend="GMemChunk">GMemChunk</link> *mem_chunk,
 
268
                                                         <link linkend="gpointer">gpointer</link> mem);</programlisting>
 
269
<warning><para><literal>g_mem_chunk_free</literal> has been deprecated since version 2.10 and should not be used in newly-written code. Use <link linkend="g-slice-free1"><function>g_slice_free1()</function></link> instead</para></warning>
 
270
<para>
 
271
Frees an atom in a <link linkend="GMemChunk"><type>GMemChunk</type></link>.
 
272
This should only be called if the <link linkend="GMemChunk"><type>GMemChunk</type></link> was created with
 
273
<link linkend="G-ALLOC-AND-FREE:CAPS"><type>G_ALLOC_AND_FREE</type></link>. Otherwise it will simply return.
 
274
</para><variablelist role="params">
 
275
<varlistentry><term><parameter>mem_chunk</parameter>&nbsp;:</term>
 
276
<listitem><simpara>a <link linkend="GMemChunk"><type>GMemChunk</type></link>.
 
277
</simpara></listitem></varlistentry>
 
278
<varlistentry><term><parameter>mem</parameter>&nbsp;:</term>
 
279
<listitem><simpara>a pointer to the atom to free.
 
280
</simpara></listitem></varlistentry>
 
281
</variablelist></refsect2>
 
282
<refsect2>
 
283
<title><anchor id="g-mem-chunk-destroy" role="function" condition="deprecated"/>g_mem_chunk_destroy ()</title>
 
284
<indexterm role="deprecated"><primary>g_mem_chunk_destroy</primary></indexterm><programlisting><link linkend="void">void</link>                g_mem_chunk_destroy                 (<link linkend="GMemChunk">GMemChunk</link> *mem_chunk);</programlisting>
 
285
<warning><para><literal>g_mem_chunk_destroy</literal> has been deprecated since version 2.10 and should not be used in newly-written code. Use the <link linkend="glib-Memory-Slices">slice 
 
286
  allocator</link> instead</para></warning>
 
287
<para>
 
288
Frees all of the memory allocated for a <link linkend="GMemChunk"><type>GMemChunk</type></link>.
 
289
</para><variablelist role="params">
 
290
<varlistentry><term><parameter>mem_chunk</parameter>&nbsp;:</term>
 
291
<listitem><simpara>a <link linkend="GMemChunk"><type>GMemChunk</type></link>.
 
292
</simpara></listitem></varlistentry>
 
293
</variablelist></refsect2>
 
294
<refsect2>
 
295
<title><anchor id="g-mem-chunk-create" role="macro" condition="deprecated"/>g_mem_chunk_create()</title>
 
296
<indexterm role="deprecated"><primary>g_mem_chunk_create</primary></indexterm><programlisting>#define             g_mem_chunk_create(type, pre_alloc, alloc_type)</programlisting>
 
297
<warning><para><literal>g_mem_chunk_create</literal> has been deprecated since version 2.10 and should not be used in newly-written code. Use the <link linkend="glib-Memory-Slices">slice 
 
298
  allocator</link> instead</para></warning>
 
299
<para>
 
300
A convenience macro for creating a new <link linkend="GMemChunk"><type>GMemChunk</type></link>.
 
301
It calls <link linkend="g-mem-chunk-new"><function>g_mem_chunk_new()</function></link>, using the given type to create the <link linkend="GMemChunk"><type>GMemChunk</type></link>
 
302
name. The atom size is determined using <function><link linkend="sizeof"><function>sizeof()</function></link></function>, and the
 
303
area size is calculated by multiplying the <parameter>pre_alloc</parameter> parameter with
 
304
the atom size.
 
305
</para><variablelist role="params">
 
306
<varlistentry><term><parameter>type</parameter>&nbsp;:</term>
 
307
<listitem><simpara>the type of the atoms, typically a structure name.
 
308
</simpara></listitem></varlistentry>
 
309
<varlistentry><term><parameter>pre_alloc</parameter>&nbsp;:</term>
 
310
<listitem><simpara>the number of atoms to store in each block of memory.
 
311
</simpara></listitem></varlistentry>
 
312
<varlistentry><term><parameter>alloc_type</parameter>&nbsp;:</term>
 
313
<listitem><simpara>the type of the <link linkend="GMemChunk"><type>GMemChunk</type></link>.
 
314
<link linkend="G-ALLOC-AND-FREE:CAPS"><type>G_ALLOC_AND_FREE</type></link> is used if the atoms will be freed individually.
 
315
<link linkend="G-ALLOC-ONLY:CAPS"><type>G_ALLOC_ONLY</type></link> should be used if atoms will never be freed individually.
 
316
<link linkend="G-ALLOC-ONLY:CAPS"><type>G_ALLOC_ONLY</type></link> is quicker, since it does not need to track free atoms,
 
317
but it obviously wastes memory if you no longer need many of the atoms.
 
318
</simpara></listitem></varlistentry>
 
319
<varlistentry><term><emphasis>Returns</emphasis>&nbsp;:</term><listitem><simpara>the new <link linkend="GMemChunk"><type>GMemChunk</type></link>.
 
320
</simpara></listitem></varlistentry>
 
321
</variablelist></refsect2>
 
322
<refsect2>
 
323
<title><anchor id="g-chunk-new" role="macro" condition="deprecated:2.10: Use g_slice_new() instead"/>g_chunk_new()</title>
 
324
<indexterm role="deprecated"><primary>g_chunk_new</primary></indexterm><programlisting>#define             g_chunk_new(type, chunk)</programlisting>
 
325
<warning><para><literal>g_chunk_new</literal> has been deprecated since version 2.10 and should not be used in newly-written code. Use <link linkend="g-slice-new"><function>g_slice_new()</function></link> instead</para></warning>
 
326
<para>
 
327
A convenience macro to allocate an atom of memory from a <link linkend="GMemChunk"><type>GMemChunk</type></link>.
 
328
It calls <link linkend="g-mem-chunk-alloc"><function>g_mem_chunk_alloc()</function></link> and casts the returned atom to a pointer to
 
329
the given type, avoiding a type cast in the source code.
 
330
</para><variablelist role="params">
 
331
<varlistentry><term><parameter>type</parameter>&nbsp;:</term>
 
332
<listitem><simpara>the type of the <link linkend="GMemChunk"><type>GMemChunk</type></link> atoms, typically a structure name.
 
333
</simpara></listitem></varlistentry>
 
334
<varlistentry><term><parameter>chunk</parameter>&nbsp;:</term>
 
335
<listitem><simpara>a <link linkend="GMemChunk"><type>GMemChunk</type></link>.
 
336
</simpara></listitem></varlistentry>
 
337
<varlistentry><term><emphasis>Returns</emphasis>&nbsp;:</term><listitem><simpara>a pointer to the allocated atom, cast to a pointer to <parameter>type</parameter>.
 
338
</simpara></listitem></varlistentry>
 
339
</variablelist></refsect2>
 
340
<refsect2>
 
341
<title><anchor id="g-chunk-new0" role="macro" condition="deprecated:2.10: Use g_slice_new0() instead"/>g_chunk_new0()</title>
 
342
<indexterm role="deprecated"><primary>g_chunk_new0</primary></indexterm><programlisting>#define             g_chunk_new0(type, chunk)</programlisting>
 
343
<warning><para><literal>g_chunk_new0</literal> has been deprecated since version 2.10 and should not be used in newly-written code. Use <link linkend="g-slice-new0"><function>g_slice_new0()</function></link> instead</para></warning>
 
344
<para>
 
345
A convenience macro to allocate an atom of memory from a <link linkend="GMemChunk"><type>GMemChunk</type></link>.
 
346
It calls <link linkend="g-mem-chunk-alloc0"><function>g_mem_chunk_alloc0()</function></link> and casts the returned atom to a pointer to
 
347
the given type, avoiding a type cast in the source code.
 
348
</para><variablelist role="params">
 
349
<varlistentry><term><parameter>type</parameter>&nbsp;:</term>
 
350
<listitem><simpara>the type of the <link linkend="GMemChunk"><type>GMemChunk</type></link> atoms, typically a structure name.
 
351
</simpara></listitem></varlistentry>
 
352
<varlistentry><term><parameter>chunk</parameter>&nbsp;:</term>
 
353
<listitem><simpara>a <link linkend="GMemChunk"><type>GMemChunk</type></link>.
 
354
</simpara></listitem></varlistentry>
 
355
<varlistentry><term><emphasis>Returns</emphasis>&nbsp;:</term><listitem><simpara>a pointer to the allocated atom, cast to a pointer to <parameter>type</parameter>.
 
356
</simpara></listitem></varlistentry>
 
357
</variablelist></refsect2>
 
358
<refsect2>
 
359
<title><anchor id="g-chunk-free" role="macro" condition="deprecated:2.10: Use g_slice_free() instead"/>g_chunk_free()</title>
 
360
<indexterm role="deprecated"><primary>g_chunk_free</primary></indexterm><programlisting>#define             g_chunk_free(mem, mem_chunk)</programlisting>
 
361
<warning><para><literal>g_chunk_free</literal> has been deprecated since version 2.10 and should not be used in newly-written code. Use <link linkend="g-slice-free"><function>g_slice_free()</function></link> instead</para></warning>
 
362
<para>
 
363
A convenience macro to free an atom of memory from a <link linkend="GMemChunk"><type>GMemChunk</type></link>.
 
364
It simply switches the arguments and calls <link linkend="g-mem-chunk-free"><function>g_mem_chunk_free()</function></link>
 
365
It is included simply to complement the other convenience macros, <link linkend="g-chunk-new"><function>g_chunk_new()</function></link>
 
366
and <link linkend="g-chunk-new0"><function>g_chunk_new0()</function></link>.
 
367
</para><variablelist role="params">
 
368
<varlistentry><term><parameter>mem</parameter>&nbsp;:</term>
 
369
<listitem><simpara>a pointer to the atom to be freed.
 
370
</simpara></listitem></varlistentry>
 
371
<varlistentry><term><parameter>mem_chunk</parameter>&nbsp;:</term>
 
372
<listitem><simpara>a <link linkend="GMemChunk"><type>GMemChunk</type></link>.
 
373
</simpara></listitem></varlistentry>
 
374
</variablelist></refsect2>
 
375
<refsect2>
 
376
<title><anchor id="g-mem-chunk-reset" role="function" condition="deprecated"/>g_mem_chunk_reset ()</title>
 
377
<indexterm role="deprecated"><primary>g_mem_chunk_reset</primary></indexterm><programlisting><link linkend="void">void</link>                g_mem_chunk_reset                   (<link linkend="GMemChunk">GMemChunk</link> *mem_chunk);</programlisting>
 
378
<warning><para><literal>g_mem_chunk_reset</literal> has been deprecated since version 2.10 and should not be used in newly-written code. Use the <link linkend="glib-Memory-Slices">slice 
 
379
  allocator</link> instead</para></warning>
 
380
<para>
 
381
Resets a GMemChunk to its initial state.
 
382
It frees all of the currently allocated blocks of memory.
 
383
</para><variablelist role="params">
 
384
<varlistentry><term><parameter>mem_chunk</parameter>&nbsp;:</term>
 
385
<listitem><simpara>a <link linkend="GMemChunk"><type>GMemChunk</type></link>.
 
386
</simpara></listitem></varlistentry>
 
387
</variablelist></refsect2>
 
388
<refsect2>
 
389
<title><anchor id="g-mem-chunk-clean" role="function" condition="deprecated"/>g_mem_chunk_clean ()</title>
 
390
<indexterm role="deprecated"><primary>g_mem_chunk_clean</primary></indexterm><programlisting><link linkend="void">void</link>                g_mem_chunk_clean                   (<link linkend="GMemChunk">GMemChunk</link> *mem_chunk);</programlisting>
 
391
<warning><para><literal>g_mem_chunk_clean</literal> has been deprecated since version 2.10 and should not be used in newly-written code. Use the <link linkend="glib-Memory-Slices">slice 
 
392
  allocator</link> instead</para></warning>
 
393
<para>
 
394
Frees any blocks in a <link linkend="GMemChunk"><type>GMemChunk</type></link> which are no longer being used.
 
395
</para><variablelist role="params">
 
396
<varlistentry><term><parameter>mem_chunk</parameter>&nbsp;:</term>
 
397
<listitem><simpara>a <link linkend="GMemChunk"><type>GMemChunk</type></link>.
 
398
</simpara></listitem></varlistentry>
 
399
</variablelist></refsect2>
 
400
<refsect2>
 
401
<title><anchor id="g-blow-chunks" role="function" condition="deprecated"/>g_blow_chunks ()</title>
 
402
<indexterm role="deprecated"><primary>g_blow_chunks</primary></indexterm><programlisting><link linkend="void">void</link>                g_blow_chunks                       (void);</programlisting>
 
403
<warning><para><literal>g_blow_chunks</literal> has been deprecated since version 2.10 and should not be used in newly-written code. Use the <link linkend="glib-Memory-Slices">slice 
 
404
  allocator</link> instead</para></warning>
 
405
<para>
 
406
Calls <link linkend="g-mem-chunk-clean"><function>g_mem_chunk_clean()</function></link> on all <link linkend="GMemChunk"><type>GMemChunk</type></link> objects.
 
407
</para></refsect2>
 
408
<refsect2>
 
409
<title><anchor id="g-mem-chunk-info" role="function" condition="deprecated"/>g_mem_chunk_info ()</title>
 
410
<indexterm role="deprecated"><primary>g_mem_chunk_info</primary></indexterm><programlisting><link linkend="void">void</link>                g_mem_chunk_info                    (void);</programlisting>
 
411
<warning><para><literal>g_mem_chunk_info</literal> has been deprecated since version 2.10 and should not be used in newly-written code. Use the <link linkend="glib-Memory-Slices">slice 
 
412
  allocator</link> instead</para></warning>
 
413
<para>
 
414
Outputs debugging information for all <link linkend="GMemChunk"><type>GMemChunk</type></link> objects currently in use.
 
415
It outputs the number of <link linkend="GMemChunk"><type>GMemChunk</type></link> objects currently allocated,
 
416
and calls <link linkend="g-mem-chunk-print"><function>g_mem_chunk_print()</function></link> to output information on each one.
 
417
</para></refsect2>
 
418
<refsect2>
 
419
<title><anchor id="g-mem-chunk-print" role="function" condition="deprecated"/>g_mem_chunk_print ()</title>
 
420
<indexterm role="deprecated"><primary>g_mem_chunk_print</primary></indexterm><programlisting><link linkend="void">void</link>                g_mem_chunk_print                   (<link linkend="GMemChunk">GMemChunk</link> *mem_chunk);</programlisting>
 
421
<warning><para><literal>g_mem_chunk_print</literal> has been deprecated since version 2.10 and should not be used in newly-written code. Use the <link linkend="glib-Memory-Slices">slice 
 
422
  allocator</link> instead</para></warning>
 
423
<para>
 
424
Outputs debugging information for a <link linkend="GMemChunk"><type>GMemChunk</type></link>.
 
425
It outputs the name of the <link linkend="GMemChunk"><type>GMemChunk</type></link> (set with <link linkend="g-mem-chunk-new"><function>g_mem_chunk_new()</function></link>),
 
426
the number of bytes used, and the number of blocks of memory allocated.
 
427
</para><variablelist role="params">
 
428
<varlistentry><term><parameter>mem_chunk</parameter>&nbsp;:</term>
 
429
<listitem><simpara>a <link linkend="GMemChunk"><type>GMemChunk</type></link>.
 
430
</simpara></listitem></varlistentry>
 
431
</variablelist></refsect2>
 
432
 
 
433
</refsect1>
 
434
 
 
435
 
 
436
 
 
437
 
 
438
</refentry>