This file is indexed.

/usr/share/doc/libglib2.0-doc/glib/glib-Memory-Slices.html is in libglib2.0-doc 2.32.1-0ubuntu2.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Memory Slices</title>
<meta name="generator" content="DocBook XSL Stylesheets V1.76.1">
<link rel="home" href="index.html" title="GLib Reference Manual">
<link rel="up" href="glib-core.html" title="GLib Core Application Support">
<link rel="prev" href="glib-Memory-Allocation.html" title="Memory Allocation">
<link rel="next" href="glib-IO-Channels.html" title="IO Channels">
<meta name="generator" content="GTK-Doc V1.18 (XML mode)">
<link rel="stylesheet" href="style.css" type="text/css">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<table class="navigation" id="top" width="100%" summary="Navigation header" cellpadding="2" cellspacing="2">
<tr valign="middle">
<td><a accesskey="p" href="glib-Memory-Allocation.html"><img src="left.png" width="24" height="24" border="0" alt="Prev"></a></td>
<td><a accesskey="u" href="glib-core.html"><img src="up.png" width="24" height="24" border="0" alt="Up"></a></td>
<td><a accesskey="h" href="index.html"><img src="home.png" width="24" height="24" border="0" alt="Home"></a></td>
<th width="100%" align="center">GLib Reference Manual</th>
<td><a accesskey="n" href="glib-IO-Channels.html"><img src="right.png" width="24" height="24" border="0" alt="Next"></a></td>
</tr>
<tr><td colspan="5" class="shortcuts">
<a href="#glib-Memory-Slices.synopsis" class="shortcut">Top</a>
                   | 
                  <a href="#glib-Memory-Slices.description" class="shortcut">Description</a>
</td></tr>
</table>
<div class="refentry">
<a name="glib-Memory-Slices"></a><div class="titlepage"></div>
<div class="refnamediv"><table width="100%"><tr>
<td valign="top">
<h2><span class="refentrytitle"><a name="glib-Memory-Slices.top_of_page"></a>Memory Slices</span></h2>
<p>Memory Slices — efficient way to allocate groups of equal-sized
    chunks of memory</p>
</td>
<td valign="top" align="right"></td>
</tr></table></div>
<div class="refsynopsisdiv">
<a name="glib-Memory-Slices.synopsis"></a><h2>Synopsis</h2>
<pre class="synopsis">
#include &lt;glib.h&gt;

<a class="link" href="glib-Basic-Types.html#gpointer" title="gpointer"><span class="returnvalue">gpointer</span></a>            <a class="link" href="glib-Memory-Slices.html#g-slice-alloc" title="g_slice_alloc ()">g_slice_alloc</a>                       (<em class="parameter"><code><span class="type">gsize</span> block_size</code></em>);
<a class="link" href="glib-Basic-Types.html#gpointer" title="gpointer"><span class="returnvalue">gpointer</span></a>            <a class="link" href="glib-Memory-Slices.html#g-slice-alloc0" title="g_slice_alloc0 ()">g_slice_alloc0</a>                      (<em class="parameter"><code><span class="type">gsize</span> block_size</code></em>);
<a class="link" href="glib-Basic-Types.html#gpointer" title="gpointer"><span class="returnvalue">gpointer</span></a>            <a class="link" href="glib-Memory-Slices.html#g-slice-copy" title="g_slice_copy ()">g_slice_copy</a>                        (<em class="parameter"><code><span class="type">gsize</span> block_size</code></em>,
                                                         <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gconstpointer" title="gconstpointer"><span class="type">gconstpointer</span></a> mem_block</code></em>);
<span class="returnvalue">void</span>                <a class="link" href="glib-Memory-Slices.html#g-slice-free1" title="g_slice_free1 ()">g_slice_free1</a>                       (<em class="parameter"><code><span class="type">gsize</span> block_size</code></em>,
                                                         <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gpointer" title="gpointer"><span class="type">gpointer</span></a> mem_block</code></em>);
<span class="returnvalue">void</span>                <a class="link" href="glib-Memory-Slices.html#g-slice-free-chain-with-offset" title="g_slice_free_chain_with_offset ()">g_slice_free_chain_with_offset</a>      (<em class="parameter"><code><span class="type">gsize</span> block_size</code></em>,
                                                         <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gpointer" title="gpointer"><span class="type">gpointer</span></a> mem_chain</code></em>,
                                                         <em class="parameter"><code><span class="type">gsize</span> next_offset</code></em>);

#define             <a class="link" href="glib-Memory-Slices.html#g-slice-new" title="g_slice_new()">g_slice_new</a>                         (type)
#define             <a class="link" href="glib-Memory-Slices.html#g-slice-new0" title="g_slice_new0()">g_slice_new0</a>                        (type)
#define             <a class="link" href="glib-Memory-Slices.html#g-slice-dup" title="g_slice_dup()">g_slice_dup</a>                         (type,
                                                         mem)
#define             <a class="link" href="glib-Memory-Slices.html#g-slice-free" title="g_slice_free()">g_slice_free</a>                        (type,
                                                         mem)
#define             <a class="link" href="glib-Memory-Slices.html#g-slice-free-chain" title="g_slice_free_chain()">g_slice_free_chain</a>                  (type,
                                                         mem_chain,
                                                         next)
</pre>
</div>
<div class="refsect1">
<a name="glib-Memory-Slices.description"></a><h2>Description</h2>
<p>
Memory slices provide a space-efficient and multi-processing scalable
way to allocate equal-sized pieces of memory, just like the original
<span class="type">GMemChunks</span> (from GLib 2.8), while avoiding their excessive
memory-waste, scalability and performance problems.
</p>
<p>
To achieve these goals, the slice allocator uses a sophisticated,
layered design that has been inspired by Bonwick's slab allocator
<sup>[<a name="idp5907400" href="#ftn.idp5907400" class="footnote">1</a>]</sup>.
It uses <code class="function">posix_memalign()</code> to optimize allocations of many equally-sized
chunks, and has per-thread free lists (the so-called magazine layer)
to quickly satisfy allocation requests of already known structure sizes.
This is accompanied by extra caching logic to keep freed memory around
for some time before returning it to the system. Memory that is unused
due to alignment constraints is used for cache colorization (random
distribution of chunk addresses) to improve CPU cache utilization. The
caching layer of the slice allocator adapts itself to high lock contention
to improve scalability.
</p>
<p>
The slice allocator can allocate blocks as small as two pointers, and
unlike <code class="function">malloc()</code>, it does not reserve extra space per block. For large block
sizes, <a class="link" href="glib-Memory-Slices.html#g-slice-new" title="g_slice_new()"><code class="function">g_slice_new()</code></a> and <a class="link" href="glib-Memory-Slices.html#g-slice-alloc" title="g_slice_alloc ()"><code class="function">g_slice_alloc()</code></a> will automatically delegate to the
system <code class="function">malloc()</code> implementation. For newly written code it is recommended
to use the new <code class="literal">g_slice</code> API instead of <a class="link" href="glib-Memory-Allocation.html#g-malloc" title="g_malloc ()"><code class="function">g_malloc()</code></a> and
friends, as long as objects are not resized during their lifetime and the
object size used at allocation time is still available when freeing.
</p>
<p>
</p>
<div class="example">
<a name="idp6058952"></a><p class="title"><b>Example 8. Using the slice allocator</b></p>
<div class="example-contents"><pre class="programlisting">
gchar *mem[10000];
gint i;

/* Allocate 10000 blocks. */
for (i = 0; i &lt; 10000; i++)
  {
    mem[i] = g_slice_alloc (50);

    /* Fill in the memory with some junk. */
    for (j = 0; j &lt; 50; j++)
      mem[i][j] = i * j;
  }

/* Now free all of the blocks. */
for (i = 0; i &lt; 10000; i++)
  {
    g_slice_free1 (50, mem[i]);
  }
</pre></div>
</div>
<p><br class="example-break">
</p>
<p>
</p>
<div class="example">
<a name="idp5229624"></a><p class="title"><b>Example 9. Using the slice allocator with data structures</b></p>
<div class="example-contents"><pre class="programlisting">
GRealArray *array;

/* Allocate one block, using the g_slice_new() macro. */
array = g_slice_new (GRealArray);

/* We can now use array just like a normal pointer to a structure. */
array-&gt;data            = NULL;
array-&gt;len             = 0;
array-&gt;alloc           = 0;
array-&gt;zero_terminated = (zero_terminated ? 1 : 0);
array-&gt;clear           = (clear ? 1 : 0);
array-&gt;elt_size        = elt_size;

/* We can free the block, so it can be reused. */
g_slice_free (GRealArray, array);
</pre></div>
</div>
<p><br class="example-break">
</p>
</div>
<div class="refsect1">
<a name="glib-Memory-Slices.details"></a><h2>Details</h2>
<div class="refsect2">
<a name="g-slice-alloc"></a><h3>g_slice_alloc ()</h3>
<pre class="programlisting"><a class="link" href="glib-Basic-Types.html#gpointer" title="gpointer"><span class="returnvalue">gpointer</span></a>            g_slice_alloc                       (<em class="parameter"><code><span class="type">gsize</span> block_size</code></em>);</pre>
<p>
Allocates a block of memory from the slice allocator.
The block adress handed out can be expected to be aligned
to at least <code class="literal">1 * sizeof (void*)</code>,
though in general slices are 2 * sizeof (void*) bytes aligned,
if a <code class="function">malloc()</code> fallback implementation is used instead,
the alignment may be reduced in a libc dependent fashion.
Note that the underlying slice allocation mechanism can
be changed with the <a class="link" href="glib-running.html#G_SLICE" title="G_SLICE">G_SLICE=always-malloc</a>
environment variable.
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>block_size</code></em> :</span></p></td>
<td>the number of bytes to allocate</td>
</tr>
<tr>
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
<td>a pointer to the allocated memory block</td>
</tr>
</tbody>
</table></div>
<p class="since">Since 2.10</p>
</div>
<hr>
<div class="refsect2">
<a name="g-slice-alloc0"></a><h3>g_slice_alloc0 ()</h3>
<pre class="programlisting"><a class="link" href="glib-Basic-Types.html#gpointer" title="gpointer"><span class="returnvalue">gpointer</span></a>            g_slice_alloc0                      (<em class="parameter"><code><span class="type">gsize</span> block_size</code></em>);</pre>
<p>
Allocates a block of memory via <a class="link" href="glib-Memory-Slices.html#g-slice-alloc" title="g_slice_alloc ()"><code class="function">g_slice_alloc()</code></a> and initializes
the returned memory to 0. Note that the underlying slice allocation
mechanism can be changed with the
<a class="link" href="glib-running.html#G_SLICE" title="G_SLICE">G_SLICE=always-malloc</a>
environment variable.
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>block_size</code></em> :</span></p></td>
<td>the number of bytes to allocate</td>
</tr>
<tr>
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
<td>a pointer to the allocated block</td>
</tr>
</tbody>
</table></div>
<p class="since">Since 2.10</p>
</div>
<hr>
<div class="refsect2">
<a name="g-slice-copy"></a><h3>g_slice_copy ()</h3>
<pre class="programlisting"><a class="link" href="glib-Basic-Types.html#gpointer" title="gpointer"><span class="returnvalue">gpointer</span></a>            g_slice_copy                        (<em class="parameter"><code><span class="type">gsize</span> block_size</code></em>,
                                                         <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gconstpointer" title="gconstpointer"><span class="type">gconstpointer</span></a> mem_block</code></em>);</pre>
<p>
Allocates a block of memory from the slice allocator
and copies <em class="parameter"><code>block_size</code></em> bytes into it from <em class="parameter"><code>mem_block</code></em>.
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>block_size</code></em> :</span></p></td>
<td>the number of bytes to allocate</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>mem_block</code></em> :</span></p></td>
<td>the memory to copy</td>
</tr>
<tr>
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
<td>a pointer to the allocated memory block</td>
</tr>
</tbody>
</table></div>
<p class="since">Since 2.14</p>
</div>
<hr>
<div class="refsect2">
<a name="g-slice-free1"></a><h3>g_slice_free1 ()</h3>
<pre class="programlisting"><span class="returnvalue">void</span>                g_slice_free1                       (<em class="parameter"><code><span class="type">gsize</span> block_size</code></em>,
                                                         <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gpointer" title="gpointer"><span class="type">gpointer</span></a> mem_block</code></em>);</pre>
<p>
Frees a block of memory.
</p>
<p>
The memory must have been allocated via <a class="link" href="glib-Memory-Slices.html#g-slice-alloc" title="g_slice_alloc ()"><code class="function">g_slice_alloc()</code></a> or
<a class="link" href="glib-Memory-Slices.html#g-slice-alloc0" title="g_slice_alloc0 ()"><code class="function">g_slice_alloc0()</code></a> and the <em class="parameter"><code>block_size</code></em> has to match the size
specified upon allocation. Note that the exact release behaviour
can be changed with the
G_DEBUG=gc-friendly environment
variable, also see <a class="link" href="glib-running.html#G_SLICE" title="G_SLICE">G_SLICE</a> for
related debugging options.
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>block_size</code></em> :</span></p></td>
<td>the size of the block</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>mem_block</code></em> :</span></p></td>
<td>a pointer to the block to free</td>
</tr>
</tbody>
</table></div>
<p class="since">Since 2.10</p>
</div>
<hr>
<div class="refsect2">
<a name="g-slice-free-chain-with-offset"></a><h3>g_slice_free_chain_with_offset ()</h3>
<pre class="programlisting"><span class="returnvalue">void</span>                g_slice_free_chain_with_offset      (<em class="parameter"><code><span class="type">gsize</span> block_size</code></em>,
                                                         <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gpointer" title="gpointer"><span class="type">gpointer</span></a> mem_chain</code></em>,
                                                         <em class="parameter"><code><span class="type">gsize</span> next_offset</code></em>);</pre>
<p>
Frees a linked list of memory blocks of structure type <em class="parameter"><code>type</code></em>.
</p>
<p>
The memory blocks must be equal-sized, allocated via
<a class="link" href="glib-Memory-Slices.html#g-slice-alloc" title="g_slice_alloc ()"><code class="function">g_slice_alloc()</code></a> or <a class="link" href="glib-Memory-Slices.html#g-slice-alloc0" title="g_slice_alloc0 ()"><code class="function">g_slice_alloc0()</code></a> and linked together by a
<em class="parameter"><code>next</code></em> pointer (similar to <a class="link" href="glib-Singly-Linked-Lists.html#GSList" title="struct GSList"><span class="type">GSList</span></a>). The offset of the <em class="parameter"><code>next</code></em>
field in each block is passed as third argument.
Note that the exact release behaviour can be changed with the
G_DEBUG=gc-friendly environment
variable, also see <a class="link" href="glib-running.html#G_SLICE" title="G_SLICE">G_SLICE</a> for
related debugging options.
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>block_size</code></em> :</span></p></td>
<td>the size of the blocks</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>mem_chain</code></em> :</span></p></td>
<td>a pointer to the first block of the chain</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>next_offset</code></em> :</span></p></td>
<td>the offset of the <em class="parameter"><code>next</code></em> field in the blocks</td>
</tr>
</tbody>
</table></div>
<p class="since">Since 2.10</p>
</div>
<hr>
<div class="refsect2">
<a name="g-slice-new"></a><h3>g_slice_new()</h3>
<pre class="programlisting">#define             g_slice_new(type)</pre>
<p>
A convenience macro to allocate a block of memory from the
slice allocator.
</p>
<p>
It calls <a class="link" href="glib-Memory-Slices.html#g-slice-alloc" title="g_slice_alloc ()"><code class="function">g_slice_alloc()</code></a> with <code class="literal">sizeof (<em class="parameter"><code>type</code></em>)</code>
and casts the returned pointer to a pointer of the given type,
avoiding a type cast in the source code.
Note that the underlying slice allocation mechanism can
be changed with the <a class="link" href="glib-running.html#G_SLICE" title="G_SLICE">G_SLICE=always-malloc</a>
environment variable.
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>type</code></em> :</span></p></td>
<td>the type to allocate, typically a structure name</td>
</tr>
<tr>
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
<td>a pointer to the allocated block, cast to a pointer to <em class="parameter"><code>type</code></em>
</td>
</tr>
</tbody>
</table></div>
<p class="since">Since 2.10</p>
</div>
<hr>
<div class="refsect2">
<a name="g-slice-new0"></a><h3>g_slice_new0()</h3>
<pre class="programlisting">#define             g_slice_new0(type)</pre>
<p>
A convenience macro to allocate a block of memory from the
slice allocator and set the memory to 0.
</p>
<p>
It calls <a class="link" href="glib-Memory-Slices.html#g-slice-alloc0" title="g_slice_alloc0 ()"><code class="function">g_slice_alloc0()</code></a> with <code class="literal">sizeof (<em class="parameter"><code>type</code></em>)</code>
and casts the returned pointer to a pointer of the given type,
avoiding a type cast in the source code.
Note that the underlying slice allocation mechanism can
be changed with the <a class="link" href="glib-running.html#G_SLICE" title="G_SLICE">G_SLICE=always-malloc</a>
environment variable.
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody><tr>
<td><p><span class="term"><em class="parameter"><code>type</code></em> :</span></p></td>
<td>the type to allocate, typically a structure name</td>
</tr></tbody>
</table></div>
<p class="since">Since 2.10</p>
</div>
<hr>
<div class="refsect2">
<a name="g-slice-dup"></a><h3>g_slice_dup()</h3>
<pre class="programlisting">#define             g_slice_dup(type, mem)</pre>
<p>
A convenience macro to duplicate a block of memory using
the slice allocator.
</p>
<p>
It calls <a class="link" href="glib-Memory-Slices.html#g-slice-copy" title="g_slice_copy ()"><code class="function">g_slice_copy()</code></a> with <code class="literal">sizeof (<em class="parameter"><code>type</code></em>)</code>
and casts the returned pointer to a pointer of the given type,
avoiding a type cast in the source code.
Note that the underlying slice allocation mechanism can
be changed with the <a class="link" href="glib-running.html#G_SLICE" title="G_SLICE">G_SLICE=always-malloc</a>
environment variable.
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>type</code></em> :</span></p></td>
<td>the type to duplicate, typically a structure name</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>mem</code></em> :</span></p></td>
<td>the memory to copy into the allocated block</td>
</tr>
<tr>
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
<td>a pointer to the allocated block, cast to a pointer to <em class="parameter"><code>type</code></em>
</td>
</tr>
</tbody>
</table></div>
<p class="since">Since 2.14</p>
</div>
<hr>
<div class="refsect2">
<a name="g-slice-free"></a><h3>g_slice_free()</h3>
<pre class="programlisting">#define             g_slice_free(type, mem)</pre>
<p>
A convenience macro to free a block of memory that has
been allocated from the slice allocator.
</p>
<p>
It calls <a class="link" href="glib-Memory-Slices.html#g-slice-free1" title="g_slice_free1 ()"><code class="function">g_slice_free1()</code></a> using <code class="literal">sizeof (type)</code>
as the block size.
Note that the exact release behaviour can be changed with the
G_DEBUG=gc-friendly environment
variable, also see <a class="link" href="glib-running.html#G_SLICE" title="G_SLICE">G_SLICE</a> for
related debugging options.
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>type</code></em> :</span></p></td>
<td>the type of the block to free, typically a structure name</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>mem</code></em> :</span></p></td>
<td>a pointer to the block to free</td>
</tr>
</tbody>
</table></div>
<p class="since">Since 2.10</p>
</div>
<hr>
<div class="refsect2">
<a name="g-slice-free-chain"></a><h3>g_slice_free_chain()</h3>
<pre class="programlisting">#define             g_slice_free_chain(type, mem_chain, next)</pre>
<p>
Frees a linked list of memory blocks of structure type <em class="parameter"><code>type</code></em>.
The memory blocks must be equal-sized, allocated via
<a class="link" href="glib-Memory-Slices.html#g-slice-alloc" title="g_slice_alloc ()"><code class="function">g_slice_alloc()</code></a> or <a class="link" href="glib-Memory-Slices.html#g-slice-alloc0" title="g_slice_alloc0 ()"><code class="function">g_slice_alloc0()</code></a> and linked together by
a <em class="parameter"><code>next</code></em> pointer (similar to <a class="link" href="glib-Singly-Linked-Lists.html#GSList" title="struct GSList"><span class="type">GSList</span></a>). The name of the
<em class="parameter"><code>next</code></em> field in <em class="parameter"><code>type</code></em> is passed as third argument.
Note that the exact release behaviour can be changed with the
G_DEBUG=gc-friendly environment
variable, also see <a class="link" href="glib-running.html#G_SLICE" title="G_SLICE">G_SLICE</a> for
related debugging options.
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>type</code></em> :</span></p></td>
<td>the type of the <em class="parameter"><code>mem_chain</code></em> blocks</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>mem_chain</code></em> :</span></p></td>
<td>a pointer to the first block of the chain</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>next</code></em> :</span></p></td>
<td>the field name of the next pointer in <em class="parameter"><code>type</code></em>
</td>
</tr>
</tbody>
</table></div>
<p class="since">Since 2.10</p>
</div>
</div>
<div class="footnotes">
<br><hr width="100" align="left">
<div class="footnote"><p><sup>[<a id="ftn.idp5907400" href="#idp5907400" class="para">1</a>] </sup>
<a class="ulink" href="http://citeseer.ist.psu.edu/bonwick94slab.html" target="_top">[Bonwick94]</a> Jeff Bonwick, The slab allocator: An object-caching kernel
memory allocator. USENIX 1994, and
<a class="ulink" href="http://citeseer.ist.psu.edu/bonwick01magazines.html" target="_top">[Bonwick01]</a> Bonwick and Jonathan Adams, Magazines and vmem: Extending the
slab allocator to many cpu's and arbitrary resources. USENIX 2001
</p></div>
</div>
</div>
<div class="footer">
<hr>
          Generated by GTK-Doc V1.18</div>
</body>
</html>