|
Server : Apache/2.2.17 (Unix) mod_ssl/2.2.17 OpenSSL/0.9.8e-fips-rhel5 DAV/2 PHP/5.2.17 System : Linux localhost 2.6.18-419.el5 #1 SMP Fri Feb 24 22:47:42 UTC 2017 x86_64 User : nobody ( 99) PHP Version : 5.2.17 Disable Function : NONE Directory : /proc/21585/root/usr/share/gtk-doc/html/glib/ |
Upload File : |
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
<title>Memory Chunks</title>
<meta name="generator" content="DocBook XSL Stylesheets V1.69.1">
<link rel="start" href="index.html" title="GLib Reference Manual">
<link rel="up" href="glib-data-types.html" title="GLib Data Types">
<link rel="prev" href="glib-Memory-Slices.html" title="Memory Slices">
<link rel="next" href="glib-Doubly-Linked-Lists.html" title="Doubly-Linked Lists">
<meta name="generator" content="GTK-Doc V1.6 (XML mode)">
<link rel="stylesheet" href="style.css" type="text/css">
<link rel="chapter" href="glib.html" title="GLib Overview">
<link rel="chapter" href="glib-fundamentals.html" title="GLib Fundamentals">
<link rel="chapter" href="glib-core.html" title="GLib Core Application Support">
<link rel="chapter" href="glib-utilities.html" title="GLib Utilities">
<link rel="chapter" href="glib-data-types.html" title="GLib Data Types">
<link rel="chapter" href="tools.html" title="GLib Tools">
<link rel="index" href="ix01.html" title="Index">
<link rel="index" href="ix02.html" title="Index of deprecated symbols">
<link rel="index" href="ix03.html" title="Index of new symbols in 2.2">
<link rel="index" href="ix04.html" title="Index of new symbols in 2.4">
<link rel="index" href="ix05.html" title="Index of new symbols in 2.6">
<link rel="index" href="ix06.html" title="Index of new symbols in 2.8">
<link rel="index" href="ix07.html" title="Index of new symbols in 2.10">
<link rel="index" href="ix08.html" title="Index of new symbols in 2.12">
</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-Slices.html"><img src="left.png" width="24" height="24" border="0" alt="Prev"></a></td>
<td><a accesskey="u" href="glib-data-types.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-Doubly-Linked-Lists.html"><img src="right.png" width="24" height="24" border="0" alt="Next"></a></td>
</tr>
<tr><td colspan="5" class="shortcuts"><nobr><a href="#id3195237" class="shortcut">Top</a>
 | 
<a href="#id3195552" class="shortcut">Description</a></nobr></td></tr>
</table>
<div class="refentry" lang="en">
<a name="glib-Memory-Chunks"></a><div class="titlepage"></div>
<div class="refnamediv"><table width="100%"><tr>
<td valign="top">
<h2>
<a name="id3195237"></a><span class="refentrytitle">Memory Chunks</span>
</h2>
<p>Memory Chunks — deprecated way to allocate groups of equal-sized chunks of memory.</p>
</td>
<td valign="top" align="right"></td>
</tr></table></div>
<div class="refsynopsisdiv">
<h2>Synopsis</h2>
<pre class="synopsis">
#include <glib.h>
<a href="glib-Memory-Chunks.html#GMemChunk">GMemChunk</a>;
#define <a href="glib-Memory-Chunks.html#G-ALLOC-AND-FREE:CAPS">G_ALLOC_AND_FREE</a>
#define <a href="glib-Memory-Chunks.html#G-ALLOC-ONLY:CAPS">G_ALLOC_ONLY</a>
<a href="glib-Memory-Chunks.html#GMemChunk">GMemChunk</a>* <a href="glib-Memory-Chunks.html#g-mem-chunk-new">g_mem_chunk_new</a> (const <a href="glib-Basic-Types.html#gchar">gchar</a> *name,
<a href="glib-Basic-Types.html#gint">gint</a> atom_size,
<a href="glib-Basic-Types.html#gulong">gulong</a> area_size,
<a href="glib-Basic-Types.html#gint">gint</a> type);
<a href="glib-Basic-Types.html#gpointer">gpointer</a> <a href="glib-Memory-Chunks.html#g-mem-chunk-alloc">g_mem_chunk_alloc</a> (<a href="glib-Memory-Chunks.html#GMemChunk">GMemChunk</a> *mem_chunk);
<a href="glib-Basic-Types.html#gpointer">gpointer</a> <a href="glib-Memory-Chunks.html#g-mem-chunk-alloc0">g_mem_chunk_alloc0</a> (<a href="glib-Memory-Chunks.html#GMemChunk">GMemChunk</a> *mem_chunk);
void <a href="glib-Memory-Chunks.html#g-mem-chunk-free">g_mem_chunk_free</a> (<a href="glib-Memory-Chunks.html#GMemChunk">GMemChunk</a> *mem_chunk,
<a href="glib-Basic-Types.html#gpointer">gpointer</a> mem);
void <a href="glib-Memory-Chunks.html#g-mem-chunk-destroy">g_mem_chunk_destroy</a> (<a href="glib-Memory-Chunks.html#GMemChunk">GMemChunk</a> *mem_chunk);
#define <a href="glib-Memory-Chunks.html#g-mem-chunk-create">g_mem_chunk_create</a> (type, pre_alloc, alloc_type)
#define <a href="glib-Memory-Chunks.html#g-chunk-new">g_chunk_new</a> (type, chunk)
#define <a href="glib-Memory-Chunks.html#g-chunk-new0">g_chunk_new0</a> (type, chunk)
#define <a href="glib-Memory-Chunks.html#g-chunk-free">g_chunk_free</a> (mem, mem_chunk)
void <a href="glib-Memory-Chunks.html#g-mem-chunk-reset">g_mem_chunk_reset</a> (<a href="glib-Memory-Chunks.html#GMemChunk">GMemChunk</a> *mem_chunk);
void <a href="glib-Memory-Chunks.html#g-mem-chunk-clean">g_mem_chunk_clean</a> (<a href="glib-Memory-Chunks.html#GMemChunk">GMemChunk</a> *mem_chunk);
void <a href="glib-Memory-Chunks.html#g-blow-chunks">g_blow_chunks</a> (void);
void <a href="glib-Memory-Chunks.html#g-mem-chunk-info">g_mem_chunk_info</a> (void);
void <a href="glib-Memory-Chunks.html#g-mem-chunk-print">g_mem_chunk_print</a> (<a href="glib-Memory-Chunks.html#GMemChunk">GMemChunk</a> *mem_chunk);
</pre>
</div>
<div class="refsect1" lang="en">
<a name="id3195552"></a><h2>Description</h2>
<p>
Memory chunks provide an space-efficient way to allocate equal-sized
pieces of memory, called atoms. However, due to the administrative
overhead (in particular for <a href="glib-Memory-Chunks.html#G-ALLOC-AND-FREE:CAPS"><span class="type">G_ALLOC_AND_FREE</span></a>, and when used from multiple
threads), they are in practise often slower than direct use of <a href="glib-Memory-Allocation.html#g-malloc"><code class="function">g_malloc()</code></a>.
Therefore, memory chunks have been deprecated in favor of the
<a href="glib-Memory-Slices.html" title="Memory Slices">slice allocator</a>,
which has been added in 2.10. All internal uses of memory chunks in
GLib have been converted to the <code class="literal">g_slice</code> API.
</p>
<p>
There are two types of memory chunks, <a href="glib-Memory-Chunks.html#G-ALLOC-ONLY:CAPS"><span class="type">G_ALLOC_ONLY</span></a>, and <a href="glib-Memory-Chunks.html#G-ALLOC-AND-FREE:CAPS"><span class="type">G_ALLOC_AND_FREE</span></a>.
</p>
<div class="itemizedlist"><ul type="disc">
<li><p>
<a href="glib-Memory-Chunks.html#G-ALLOC-ONLY:CAPS"><span class="type">G_ALLOC_ONLY</span></a> chunks only allow allocation of atoms. The atoms can never
be freed individually. The memory chunk can only be free in its entirety.
</p></li>
<li><p>
<a href="glib-Memory-Chunks.html#G-ALLOC-AND-FREE:CAPS"><span class="type">G_ALLOC_AND_FREE</span></a> chunks do allow atoms to be freed individually.
The disadvantage of this is that the memory chunk has to keep track of which
atoms have been freed. This results in more memory being used and a slight
degradation in performance.
</p></li>
</ul></div>
<p>
</p>
<p>
To create a memory chunk use <a href="glib-Memory-Chunks.html#g-mem-chunk-new"><code class="function">g_mem_chunk_new()</code></a> or the convenience macro
<a href="glib-Memory-Chunks.html#g-mem-chunk-create"><code class="function">g_mem_chunk_create()</code></a>.
</p>
<p>
To allocate a new atom use <a href="glib-Memory-Chunks.html#g-mem-chunk-alloc"><code class="function">g_mem_chunk_alloc()</code></a>, <a href="glib-Memory-Chunks.html#g-mem-chunk-alloc0"><code class="function">g_mem_chunk_alloc0()</code></a>,
or the convenience macros <a href="glib-Memory-Chunks.html#g-chunk-new"><code class="function">g_chunk_new()</code></a> or <a href="glib-Memory-Chunks.html#g-chunk-new0"><code class="function">g_chunk_new0()</code></a>.
</p>
<p>
To free an atom use <a href="glib-Memory-Chunks.html#g-mem-chunk-free"><code class="function">g_mem_chunk_free()</code></a>, or the convenience macro
<a href="glib-Memory-Chunks.html#g-chunk-free"><code class="function">g_chunk_free()</code></a>. (Atoms can only be freed if the memory chunk is created
with the type set to <a href="glib-Memory-Chunks.html#G-ALLOC-AND-FREE:CAPS"><span class="type">G_ALLOC_AND_FREE</span></a>.)
</p>
<p>
To free any blocks of memory which are no longer being used, use
<a href="glib-Memory-Chunks.html#g-mem-chunk-clean"><code class="function">g_mem_chunk_clean()</code></a>. To clean all memory chunks, use <a href="glib-Memory-Chunks.html#g-blow-chunks"><code class="function">g_blow_chunks()</code></a>.
</p>
<p>
To reset the memory chunk, freeing all of the atoms, use <a href="glib-Memory-Chunks.html#g-mem-chunk-reset"><code class="function">g_mem_chunk_reset()</code></a>.
</p>
<p>
To destroy a memory chunk, use <a href="glib-Memory-Chunks.html#g-mem-chunk-destroy"><code class="function">g_mem_chunk_destroy()</code></a>.
</p>
<p>
To help debug memory chunks, use <a href="glib-Memory-Chunks.html#g-mem-chunk-info"><code class="function">g_mem_chunk_info()</code></a> and <a href="glib-Memory-Chunks.html#g-mem-chunk-print"><code class="function">g_mem_chunk_print()</code></a>.
</p>
<div class="example">
<a name="id3195848"></a><p class="title"><b>Example 3. Using a <span class="structname">GMemChunk</span></b></p>
<pre class="programlisting">
GMemChunk *mem_chunk;
gchar *mem[10000];
gint i;
/* Create a GMemChunk with atoms 50 bytes long, and memory blocks holding
100 bytes. Note that this means that only 2 atoms fit into each memory
block and so isn't very efficient. */
mem_chunk = g_mem_chunk_new ("test mem chunk", 50, 100, G_ALLOC_AND_FREE);
/* Now allocate 10000 atoms. */
for (i = 0; i < 10000; i++)
{
mem[i] = g_chunk_new (gchar, mem_chunk);
/* Fill in the atom memory with some junk. */
for (j = 0; j < 50; j++)
mem[i][j] = i * j;
}
/* Now free all of the atoms. Note that since we are going to destroy the
GMemChunk, this wouldn't normally be used. */
for (i = 0; i < 10000; i++)
{
g_mem_chunk_free (mem_chunk, mem[i]);
}
/* We are finished with the GMemChunk, so we destroy it. */
g_mem_chunk_destroy (mem_chunk);
</pre>
</div>
<div class="example">
<a name="id3195892"></a><p class="title"><b>Example 4. Using a <span class="structname">GMemChunk</span> with data structures</b></p>
<pre class="programlisting">
GMemChunk *array_mem_chunk;
GRealArray *array;
/* Create a GMemChunk to hold GRealArray structures, using the
g_mem_chunk_create() convenience macro. We want 1024 atoms in each
memory block, and we want to be able to free individual atoms. */
array_mem_chunk = g_mem_chunk_create (GRealArray, 1024, G_ALLOC_AND_FREE);
/* Allocate one atom, using the g_chunk_new() convenience macro. */
array = g_chunk_new (GRealArray, array_mem_chunk);
/* We can now use array just like a normal pointer to a structure. */
array->data = NULL;
array->len = 0;
array->alloc = 0;
array->zero_terminated = (zero_terminated ? 1 : 0);
array->clear = (clear ? 1 : 0);
array->elt_size = elt_size;
/* We can free the element, so it can be reused. */
g_chunk_free (array, array_mem_chunk);
/* We destroy the GMemChunk when we are finished with it. */
g_mem_chunk_destroy (array_mem_chunk);
</pre>
</div>
</div>
<div class="refsect1" lang="en">
<a name="id3195930"></a><h2>Details</h2>
<div class="refsect2" lang="en">
<a name="id3195940"></a><h3>
<a name="GMemChunk"></a>GMemChunk</h3>
<a class="indexterm" name="id3195955"></a><pre class="programlisting">typedef struct _GMemChunk GMemChunk;</pre>
<div class="warning" style="margin-left: 0.5in; margin-right: 0.5in;">
<h3 class="title">Warning</h3>
<p><code class="literal">GMemChunk</code> is deprecated and should not be used in newly-written code.</p>
</div>
<p>
The <a href="glib-Memory-Chunks.html#GMemChunk"><span class="type">GMemChunk</span></a> struct is an opaque data structure representing a memory
chunk. It should be accessed only through the use of the following functions.
</p>
</div>
<hr>
<div class="refsect2" lang="en">
<a name="id3195993"></a><h3>
<a name="G-ALLOC-AND-FREE:CAPS"></a>G_ALLOC_AND_FREE</h3>
<a class="indexterm" name="id3196009"></a><pre class="programlisting">#define G_ALLOC_AND_FREE 2
</pre>
<div class="warning" style="margin-left: 0.5in; margin-right: 0.5in;">
<h3 class="title">Warning</h3>
<p><code class="literal">G_ALLOC_AND_FREE</code> is deprecated and should not be used in newly-written code.</p>
</div>
<p>
Specifies the type of a <a href="glib-Memory-Chunks.html#GMemChunk"><span class="type">GMemChunk</span></a>.
Used in <a href="glib-Memory-Chunks.html#g-mem-chunk-new"><code class="function">g_mem_chunk_new()</code></a> and <a href="glib-Memory-Chunks.html#g-mem-chunk-create"><code class="function">g_mem_chunk_create()</code></a> to specify that atoms
will be freed individually.
</p>
</div>
<hr>
<div class="refsect2" lang="en">
<a name="id3196067"></a><h3>
<a name="G-ALLOC-ONLY:CAPS"></a>G_ALLOC_ONLY</h3>
<a class="indexterm" name="id3196082"></a><pre class="programlisting">#define G_ALLOC_ONLY 1
</pre>
<div class="warning" style="margin-left: 0.5in; margin-right: 0.5in;">
<h3 class="title">Warning</h3>
<p><code class="literal">G_ALLOC_ONLY</code> is deprecated and should not be used in newly-written code.</p>
</div>
<p>
Specifies the type of a <a href="glib-Memory-Chunks.html#GMemChunk"><span class="type">GMemChunk</span></a>.
Used in <a href="glib-Memory-Chunks.html#g-mem-chunk-new"><code class="function">g_mem_chunk_new()</code></a> and <a href="glib-Memory-Chunks.html#g-mem-chunk-create"><code class="function">g_mem_chunk_create()</code></a> to specify that atoms
will never be freed individually.
</p>
</div>
<hr>
<div class="refsect2" lang="en">
<a name="id3196141"></a><h3>
<a name="g-mem-chunk-new"></a>g_mem_chunk_new ()</h3>
<a class="indexterm" name="id3196155"></a><pre class="programlisting"><a href="glib-Memory-Chunks.html#GMemChunk">GMemChunk</a>* g_mem_chunk_new (const <a href="glib-Basic-Types.html#gchar">gchar</a> *name,
<a href="glib-Basic-Types.html#gint">gint</a> atom_size,
<a href="glib-Basic-Types.html#gulong">gulong</a> area_size,
<a href="glib-Basic-Types.html#gint">gint</a> type);</pre>
<div class="warning" style="margin-left: 0.5in; margin-right: 0.5in;">
<h3 class="title">Warning</h3>
<p><code class="literal">g_mem_chunk_new</code> has been deprecated since version 2.10 and should not be used in newly-written code. Use the <a href="glib-Memory-Slices.html" title="Memory Slices">slice allocator</a>
instead</p>
</div>
<p>
Creates a new <a href="glib-Memory-Chunks.html#GMemChunk"><span class="type">GMemChunk</span></a>.
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td>
<span class="term"><em class="parameter"><code>name</code></em> :</span></td>
<td>a string to identify the <a href="glib-Memory-Chunks.html#GMemChunk"><span class="type">GMemChunk</span></a>. It is not copied so it
should be valid for the lifetime of the <a href="glib-Memory-Chunks.html#GMemChunk"><span class="type">GMemChunk</span></a>. It is only used in
<a href="glib-Memory-Chunks.html#g-mem-chunk-print"><code class="function">g_mem_chunk_print()</code></a>, which is used for debugging.
</td>
</tr>
<tr>
<td>
<span class="term"><em class="parameter"><code>atom_size</code></em> :</span></td>
<td>the size, in bytes, of each element in the <a href="glib-Memory-Chunks.html#GMemChunk"><span class="type">GMemChunk</span></a>.
</td>
</tr>
<tr>
<td>
<span class="term"><em class="parameter"><code>area_size</code></em> :</span></td>
<td>the size, in bytes, of each block of memory allocated to contain
the atoms.
</td>
</tr>
<tr>
<td>
<span class="term"><em class="parameter"><code>type</code></em> :</span></td>
<td>the type of the <a href="glib-Memory-Chunks.html#GMemChunk"><span class="type">GMemChunk</span></a>.
<a href="glib-Memory-Chunks.html#G-ALLOC-AND-FREE:CAPS"><span class="type">G_ALLOC_AND_FREE</span></a> is used if the atoms will be freed individually.
<a href="glib-Memory-Chunks.html#G-ALLOC-ONLY:CAPS"><span class="type">G_ALLOC_ONLY</span></a> should be used if atoms will never be freed individually.
<a href="glib-Memory-Chunks.html#G-ALLOC-ONLY:CAPS"><span class="type">G_ALLOC_ONLY</span></a> is quicker, since it does not need to track free atoms,
but it obviously wastes memory if you no longer need many of the atoms.
</td>
</tr>
<tr>
<td>
<span class="term"><span class="emphasis"><em>Returns</em></span> :</span></td>
<td>the new <a href="glib-Memory-Chunks.html#GMemChunk"><span class="type">GMemChunk</span></a>.
</td>
</tr>
</tbody>
</table></div>
</div>
<hr>
<div class="refsect2" lang="en">
<a name="id3196388"></a><h3>
<a name="g-mem-chunk-alloc"></a>g_mem_chunk_alloc ()</h3>
<a class="indexterm" name="id3196404"></a><pre class="programlisting"><a href="glib-Basic-Types.html#gpointer">gpointer</a> g_mem_chunk_alloc (<a href="glib-Memory-Chunks.html#GMemChunk">GMemChunk</a> *mem_chunk);</pre>
<div class="warning" style="margin-left: 0.5in; margin-right: 0.5in;">
<h3 class="title">Warning</h3>
<p><code class="literal">g_mem_chunk_alloc</code> has been deprecated since version 2.10 and should not be used in newly-written code. Use <a href="glib-Memory-Slices.html#g-slice-alloc"><code class="function">g_slice_alloc()</code></a> instead</p>
</div>
<p>
Allocates an atom of memory from a <a href="glib-Memory-Chunks.html#GMemChunk"><span class="type">GMemChunk</span></a>.
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td>
<span class="term"><em class="parameter"><code>mem_chunk</code></em> :</span></td>
<td>a <a href="glib-Memory-Chunks.html#GMemChunk"><span class="type">GMemChunk</span></a>.
</td>
</tr>
<tr>
<td>
<span class="term"><span class="emphasis"><em>Returns</em></span> :</span></td>
<td>a pointer to the allocated atom.
</td>
</tr>
</tbody>
</table></div>
</div>
<hr>
<div class="refsect2" lang="en">
<a name="id3196500"></a><h3>
<a name="g-mem-chunk-alloc0"></a>g_mem_chunk_alloc0 ()</h3>
<a class="indexterm" name="id3196516"></a><pre class="programlisting"><a href="glib-Basic-Types.html#gpointer">gpointer</a> g_mem_chunk_alloc0 (<a href="glib-Memory-Chunks.html#GMemChunk">GMemChunk</a> *mem_chunk);</pre>
<div class="warning" style="margin-left: 0.5in; margin-right: 0.5in;">
<h3 class="title">Warning</h3>
<p><code class="literal">g_mem_chunk_alloc0</code> has been deprecated since version 2.10 and should not be used in newly-written code. Use <a href="glib-Memory-Slices.html#g-slice-alloc0"><code class="function">g_slice_alloc0()</code></a> instead</p>
</div>
<p>
Allocates an atom of memory from a <a href="glib-Memory-Chunks.html#GMemChunk"><span class="type">GMemChunk</span></a>, setting the memory to 0.
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td>
<span class="term"><em class="parameter"><code>mem_chunk</code></em> :</span></td>
<td>a <a href="glib-Memory-Chunks.html#GMemChunk"><span class="type">GMemChunk</span></a>.
</td>
</tr>
<tr>
<td>
<span class="term"><span class="emphasis"><em>Returns</em></span> :</span></td>
<td>a pointer to the allocated atom.
</td>
</tr>
</tbody>
</table></div>
</div>
<hr>
<div class="refsect2" lang="en">
<a name="id3196613"></a><h3>
<a name="g-mem-chunk-free"></a>g_mem_chunk_free ()</h3>
<a class="indexterm" name="id3196629"></a><pre class="programlisting">void g_mem_chunk_free (<a href="glib-Memory-Chunks.html#GMemChunk">GMemChunk</a> *mem_chunk,
<a href="glib-Basic-Types.html#gpointer">gpointer</a> mem);</pre>
<div class="warning" style="margin-left: 0.5in; margin-right: 0.5in;">
<h3 class="title">Warning</h3>
<p><code class="literal">g_mem_chunk_free</code> has been deprecated since version 2.10 and should not be used in newly-written code. Use <a href="glib-Memory-Slices.html#g-slice-free1"><code class="function">g_slice_free1()</code></a> instead</p>
</div>
<p>
Frees an atom in a <a href="glib-Memory-Chunks.html#GMemChunk"><span class="type">GMemChunk</span></a>.
This should only be called if the <a href="glib-Memory-Chunks.html#GMemChunk"><span class="type">GMemChunk</span></a> was created with
<a href="glib-Memory-Chunks.html#G-ALLOC-AND-FREE:CAPS"><span class="type">G_ALLOC_AND_FREE</span></a>. Otherwise it will simply return.
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td>
<span class="term"><em class="parameter"><code>mem_chunk</code></em> :</span></td>
<td>a <a href="glib-Memory-Chunks.html#GMemChunk"><span class="type">GMemChunk</span></a>.
</td>
</tr>
<tr>
<td>
<span class="term"><em class="parameter"><code>mem</code></em> :</span></td>
<td>a pointer to the atom to free.
</td>
</tr>
</tbody>
</table></div>
</div>
<hr>
<div class="refsect2" lang="en">
<a name="id3196755"></a><h3>
<a name="g-mem-chunk-destroy"></a>g_mem_chunk_destroy ()</h3>
<a class="indexterm" name="id3196770"></a><pre class="programlisting">void g_mem_chunk_destroy (<a href="glib-Memory-Chunks.html#GMemChunk">GMemChunk</a> *mem_chunk);</pre>
<div class="warning" style="margin-left: 0.5in; margin-right: 0.5in;">
<h3 class="title">Warning</h3>
<p><code class="literal">g_mem_chunk_destroy</code> has been deprecated since version 2.10 and should not be used in newly-written code. Use the <a href="glib-Memory-Slices.html" title="Memory Slices">slice
allocator</a> instead</p>
</div>
<p>
Frees all of the memory allocated for a <a href="glib-Memory-Chunks.html#GMemChunk"><span class="type">GMemChunk</span></a>.
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody><tr>
<td>
<span class="term"><em class="parameter"><code>mem_chunk</code></em> :</span></td>
<td>a <a href="glib-Memory-Chunks.html#GMemChunk"><span class="type">GMemChunk</span></a>.
</td>
</tr></tbody>
</table></div>
</div>
<hr>
<div class="refsect2" lang="en">
<a name="id3196852"></a><h3>
<a name="g-mem-chunk-create"></a>g_mem_chunk_create()</h3>
<a class="indexterm" name="id3196868"></a><pre class="programlisting">#define g_mem_chunk_create(type, pre_alloc, alloc_type)</pre>
<div class="warning" style="margin-left: 0.5in; margin-right: 0.5in;">
<h3 class="title">Warning</h3>
<p><code class="literal">g_mem_chunk_create</code> has been deprecated since version 2.10 and should not be used in newly-written code. Use the <a href="glib-Memory-Slices.html" title="Memory Slices">slice
allocator</a> instead</p>
</div>
<p>
A convenience macro for creating a new <a href="glib-Memory-Chunks.html#GMemChunk"><span class="type">GMemChunk</span></a>.
It calls <a href="glib-Memory-Chunks.html#g-mem-chunk-new"><code class="function">g_mem_chunk_new()</code></a>, using the given type to create the <a href="glib-Memory-Chunks.html#GMemChunk"><span class="type">GMemChunk</span></a>
name. The atom size is determined using <code class="function"><code class="function">sizeof()</code></code>, and the
area size is calculated by multiplying the <em class="parameter"><code>pre_alloc</code></em> parameter with
the atom size.
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td>
<span class="term"><em class="parameter"><code>type</code></em> :</span></td>
<td>the type of the atoms, typically a structure name.
</td>
</tr>
<tr>
<td>
<span class="term"><em class="parameter"><code>pre_alloc</code></em> :</span></td>
<td>the number of atoms to store in each block of memory.
</td>
</tr>
<tr>
<td>
<span class="term"><em class="parameter"><code>alloc_type</code></em> :</span></td>
<td>the type of the <a href="glib-Memory-Chunks.html#GMemChunk"><span class="type">GMemChunk</span></a>.
<a href="glib-Memory-Chunks.html#G-ALLOC-AND-FREE:CAPS"><span class="type">G_ALLOC_AND_FREE</span></a> is used if the atoms will be freed individually.
<a href="glib-Memory-Chunks.html#G-ALLOC-ONLY:CAPS"><span class="type">G_ALLOC_ONLY</span></a> should be used if atoms will never be freed individually.
<a href="glib-Memory-Chunks.html#G-ALLOC-ONLY:CAPS"><span class="type">G_ALLOC_ONLY</span></a> is quicker, since it does not need to track free atoms,
but it obviously wastes memory if you no longer need many of the atoms.
</td>
</tr>
<tr>
<td>
<span class="term"><span class="emphasis"><em>Returns</em></span> :</span></td>
<td>the new <a href="glib-Memory-Chunks.html#GMemChunk"><span class="type">GMemChunk</span></a>.
</td>
</tr>
</tbody>
</table></div>
</div>
<hr>
<div class="refsect2" lang="en">
<a name="id3197057"></a><h3>
<a name="g-chunk-new"></a>g_chunk_new()</h3>
<a class="indexterm" name="id3197071"></a><pre class="programlisting">#define g_chunk_new(type, chunk)</pre>
<div class="warning" style="margin-left: 0.5in; margin-right: 0.5in;">
<h3 class="title">Warning</h3>
<p><code class="literal">g_chunk_new</code> has been deprecated since version 2.10 and should not be used in newly-written code. Use <a href="glib-Memory-Slices.html#g-slice-new"><code class="function">g_slice_new()</code></a> instead</p>
</div>
<p>
A convenience macro to allocate an atom of memory from a <a href="glib-Memory-Chunks.html#GMemChunk"><span class="type">GMemChunk</span></a>.
It calls <a href="glib-Memory-Chunks.html#g-mem-chunk-alloc"><code class="function">g_mem_chunk_alloc()</code></a> and casts the returned atom to a pointer to
the given type, avoiding a type cast in the source code.
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td>
<span class="term"><em class="parameter"><code>type</code></em> :</span></td>
<td>the type of the <a href="glib-Memory-Chunks.html#GMemChunk"><span class="type">GMemChunk</span></a> atoms, typically a structure name.
</td>
</tr>
<tr>
<td>
<span class="term"><em class="parameter"><code>chunk</code></em> :</span></td>
<td>a <a href="glib-Memory-Chunks.html#GMemChunk"><span class="type">GMemChunk</span></a>.
</td>
</tr>
<tr>
<td>
<span class="term"><span class="emphasis"><em>Returns</em></span> :</span></td>
<td>a pointer to the allocated atom, cast to a pointer to <em class="parameter"><code>type</code></em>.
</td>
</tr>
</tbody>
</table></div>
</div>
<hr>
<div class="refsect2" lang="en">
<a name="id3197196"></a><h3>
<a name="g-chunk-new0"></a>g_chunk_new0()</h3>
<a class="indexterm" name="id3197211"></a><pre class="programlisting">#define g_chunk_new0(type, chunk)</pre>
<div class="warning" style="margin-left: 0.5in; margin-right: 0.5in;">
<h3 class="title">Warning</h3>
<p><code class="literal">g_chunk_new0</code> has been deprecated since version 2.10 and should not be used in newly-written code. Use <a href="glib-Memory-Slices.html#g-slice-new0"><code class="function">g_slice_new0()</code></a> instead</p>
</div>
<p>
A convenience macro to allocate an atom of memory from a <a href="glib-Memory-Chunks.html#GMemChunk"><span class="type">GMemChunk</span></a>.
It calls <a href="glib-Memory-Chunks.html#g-mem-chunk-alloc0"><code class="function">g_mem_chunk_alloc0()</code></a> and casts the returned atom to a pointer to
the given type, avoiding a type cast in the source code.
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td>
<span class="term"><em class="parameter"><code>type</code></em> :</span></td>
<td>the type of the <a href="glib-Memory-Chunks.html#GMemChunk"><span class="type">GMemChunk</span></a> atoms, typically a structure name.
</td>
</tr>
<tr>
<td>
<span class="term"><em class="parameter"><code>chunk</code></em> :</span></td>
<td>a <a href="glib-Memory-Chunks.html#GMemChunk"><span class="type">GMemChunk</span></a>.
</td>
</tr>
<tr>
<td>
<span class="term"><span class="emphasis"><em>Returns</em></span> :</span></td>
<td>a pointer to the allocated atom, cast to a pointer to <em class="parameter"><code>type</code></em>.
</td>
</tr>
</tbody>
</table></div>
</div>
<hr>
<div class="refsect2" lang="en">
<a name="id3197337"></a><h3>
<a name="g-chunk-free"></a>g_chunk_free()</h3>
<a class="indexterm" name="id3197352"></a><pre class="programlisting">#define g_chunk_free(mem, mem_chunk)</pre>
<div class="warning" style="margin-left: 0.5in; margin-right: 0.5in;">
<h3 class="title">Warning</h3>
<p><code class="literal">g_chunk_free</code> has been deprecated since version 2.10 and should not be used in newly-written code. Use <a href="glib-Memory-Slices.html#g-slice-free"><code class="function">g_slice_free()</code></a> instead</p>
</div>
<p>
A convenience macro to free an atom of memory from a <a href="glib-Memory-Chunks.html#GMemChunk"><span class="type">GMemChunk</span></a>.
It simply switches the arguments and calls <a href="glib-Memory-Chunks.html#g-mem-chunk-free"><code class="function">g_mem_chunk_free()</code></a>
It is included simply to complement the other convenience macros, <a href="glib-Memory-Chunks.html#g-chunk-new"><code class="function">g_chunk_new()</code></a>
and <a href="glib-Memory-Chunks.html#g-chunk-new0"><code class="function">g_chunk_new0()</code></a>.
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td>
<span class="term"><em class="parameter"><code>mem</code></em> :</span></td>
<td>a pointer to the atom to be freed.
</td>
</tr>
<tr>
<td>
<span class="term"><em class="parameter"><code>mem_chunk</code></em> :</span></td>
<td>a <a href="glib-Memory-Chunks.html#GMemChunk"><span class="type">GMemChunk</span></a>.
</td>
</tr>
</tbody>
</table></div>
</div>
<hr>
<div class="refsect2" lang="en">
<a name="id3197473"></a><h3>
<a name="g-mem-chunk-reset"></a>g_mem_chunk_reset ()</h3>
<a class="indexterm" name="id3197488"></a><pre class="programlisting">void g_mem_chunk_reset (<a href="glib-Memory-Chunks.html#GMemChunk">GMemChunk</a> *mem_chunk);</pre>
<div class="warning" style="margin-left: 0.5in; margin-right: 0.5in;">
<h3 class="title">Warning</h3>
<p><code class="literal">g_mem_chunk_reset</code> has been deprecated since version 2.10 and should not be used in newly-written code. Use the <a href="glib-Memory-Slices.html" title="Memory Slices">slice
allocator</a> instead</p>
</div>
<p>
Resets a GMemChunk to its initial state.
It frees all of the currently allocated blocks of memory.
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody><tr>
<td>
<span class="term"><em class="parameter"><code>mem_chunk</code></em> :</span></td>
<td>a <a href="glib-Memory-Chunks.html#GMemChunk"><span class="type">GMemChunk</span></a>.
</td>
</tr></tbody>
</table></div>
</div>
<hr>
<div class="refsect2" lang="en">
<a name="id3197564"></a><h3>
<a name="g-mem-chunk-clean"></a>g_mem_chunk_clean ()</h3>
<a class="indexterm" name="id3197579"></a><pre class="programlisting">void g_mem_chunk_clean (<a href="glib-Memory-Chunks.html#GMemChunk">GMemChunk</a> *mem_chunk);</pre>
<div class="warning" style="margin-left: 0.5in; margin-right: 0.5in;">
<h3 class="title">Warning</h3>
<p><code class="literal">g_mem_chunk_clean</code> has been deprecated since version 2.10 and should not be used in newly-written code. Use the <a href="glib-Memory-Slices.html" title="Memory Slices">slice
allocator</a> instead</p>
</div>
<p>
Frees any blocks in a <a href="glib-Memory-Chunks.html#GMemChunk"><span class="type">GMemChunk</span></a> which are no longer being used.
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody><tr>
<td>
<span class="term"><em class="parameter"><code>mem_chunk</code></em> :</span></td>
<td>a <a href="glib-Memory-Chunks.html#GMemChunk"><span class="type">GMemChunk</span></a>.
</td>
</tr></tbody>
</table></div>
</div>
<hr>
<div class="refsect2" lang="en">
<a name="id3197661"></a><h3>
<a name="g-blow-chunks"></a>g_blow_chunks ()</h3>
<a class="indexterm" name="id3197676"></a><pre class="programlisting">void g_blow_chunks (void);</pre>
<div class="warning" style="margin-left: 0.5in; margin-right: 0.5in;">
<h3 class="title">Warning</h3>
<p><code class="literal">g_blow_chunks</code> has been deprecated since version 2.10 and should not be used in newly-written code. Use the <a href="glib-Memory-Slices.html" title="Memory Slices">slice
allocator</a> instead</p>
</div>
<p>
Calls <a href="glib-Memory-Chunks.html#g-mem-chunk-clean"><code class="function">g_mem_chunk_clean()</code></a> on all <a href="glib-Memory-Chunks.html#GMemChunk"><span class="type">GMemChunk</span></a> objects.
</p>
</div>
<hr>
<div class="refsect2" lang="en">
<a name="id3197737"></a><h3>
<a name="g-mem-chunk-info"></a>g_mem_chunk_info ()</h3>
<a class="indexterm" name="id3197751"></a><pre class="programlisting">void g_mem_chunk_info (void);</pre>
<div class="warning" style="margin-left: 0.5in; margin-right: 0.5in;">
<h3 class="title">Warning</h3>
<p><code class="literal">g_mem_chunk_info</code> has been deprecated since version 2.10 and should not be used in newly-written code. Use the <a href="glib-Memory-Slices.html" title="Memory Slices">slice
allocator</a> instead</p>
</div>
<p>
Outputs debugging information for all <a href="glib-Memory-Chunks.html#GMemChunk"><span class="type">GMemChunk</span></a> objects currently in use.
It outputs the number of <a href="glib-Memory-Chunks.html#GMemChunk"><span class="type">GMemChunk</span></a> objects currently allocated,
and calls <a href="glib-Memory-Chunks.html#g-mem-chunk-print"><code class="function">g_mem_chunk_print()</code></a> to output information on each one.
</p>
</div>
<hr>
<div class="refsect2" lang="en">
<a name="id3197822"></a><h3>
<a name="g-mem-chunk-print"></a>g_mem_chunk_print ()</h3>
<a class="indexterm" name="id3197837"></a><pre class="programlisting">void g_mem_chunk_print (<a href="glib-Memory-Chunks.html#GMemChunk">GMemChunk</a> *mem_chunk);</pre>
<div class="warning" style="margin-left: 0.5in; margin-right: 0.5in;">
<h3 class="title">Warning</h3>
<p><code class="literal">g_mem_chunk_print</code> has been deprecated since version 2.10 and should not be used in newly-written code. Use the <a href="glib-Memory-Slices.html" title="Memory Slices">slice
allocator</a> instead</p>
</div>
<p>
Outputs debugging information for a <a href="glib-Memory-Chunks.html#GMemChunk"><span class="type">GMemChunk</span></a>.
It outputs the name of the <a href="glib-Memory-Chunks.html#GMemChunk"><span class="type">GMemChunk</span></a> (set with <a href="glib-Memory-Chunks.html#g-mem-chunk-new"><code class="function">g_mem_chunk_new()</code></a>),
the number of bytes used, and the number of blocks of memory allocated.
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody><tr>
<td>
<span class="term"><em class="parameter"><code>mem_chunk</code></em> :</span></td>
<td>a <a href="glib-Memory-Chunks.html#GMemChunk"><span class="type">GMemChunk</span></a>.
</td>
</tr></tbody>
</table></div>
</div>
</div>
</div>
</body>
</html>