| <!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 Chunks</title> |
| <meta name="generator" content="DocBook XSL Stylesheets V1.75.2"> |
| <link rel="home" 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.14 (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-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"> |
| <a href="#glib-Memory-Chunks.synopsis" class="shortcut">Top</a> |
| | |
| <a href="#glib-Memory-Chunks.description" class="shortcut">Description</a> |
| </td></tr> |
| </table> |
| <div class="refentry" title="Memory Chunks"> |
| <a name="glib-Memory-Chunks"></a><div class="titlepage"></div> |
| <div class="refnamediv"><table width="100%"><tr> |
| <td valign="top"> |
| <h2><span class="refentrytitle"><a name="glib-Memory-Chunks.top_of_page"></a>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" title="Synopsis"> |
| <a name="glib-Memory-Chunks.synopsis"></a><h2>Synopsis</h2> |
| <pre class="synopsis"> |
| #include <glib.h> |
| |
| <a class="link" href="glib-Memory-Chunks.html#GMemChunk" title="GMemChunk">GMemChunk</a>; |
| #define <a class="link" href="glib-Memory-Chunks.html#G-ALLOC-AND-FREE:CAPS" title="G_ALLOC_AND_FREE">G_ALLOC_AND_FREE</a> |
| #define <a class="link" href="glib-Memory-Chunks.html#G-ALLOC-ONLY:CAPS" title="G_ALLOC_ONLY">G_ALLOC_ONLY</a> |
| |
| <a class="link" href="glib-Memory-Chunks.html#GMemChunk" title="GMemChunk"><span class="returnvalue">GMemChunk</span></a>* <a class="link" href="glib-Memory-Chunks.html#g-mem-chunk-new" title="g_mem_chunk_new ()">g_mem_chunk_new</a> (<em class="parameter"><code>const <a class="link" href="glib-Basic-Types.html#gchar" title="gchar"><span class="type">gchar</span></a> *name</code></em>, |
| <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gint" title="gint"><span class="type">gint</span></a> atom_size</code></em>, |
| <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gsize" title="gsize"><span class="type">gsize</span></a> area_size</code></em>, |
| <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gint" title="gint"><span class="type">gint</span></a> type</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-Chunks.html#g-mem-chunk-alloc" title="g_mem_chunk_alloc ()">g_mem_chunk_alloc</a> (<em class="parameter"><code><a class="link" href="glib-Memory-Chunks.html#GMemChunk" title="GMemChunk"><span class="type">GMemChunk</span></a> *mem_chunk</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-Chunks.html#g-mem-chunk-alloc0" title="g_mem_chunk_alloc0 ()">g_mem_chunk_alloc0</a> (<em class="parameter"><code><a class="link" href="glib-Memory-Chunks.html#GMemChunk" title="GMemChunk"><span class="type">GMemChunk</span></a> *mem_chunk</code></em>); |
| <span class="returnvalue">void</span> <a class="link" href="glib-Memory-Chunks.html#g-mem-chunk-free" title="g_mem_chunk_free ()">g_mem_chunk_free</a> (<em class="parameter"><code><a class="link" href="glib-Memory-Chunks.html#GMemChunk" title="GMemChunk"><span class="type">GMemChunk</span></a> *mem_chunk</code></em>, |
| <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gpointer" title="gpointer"><span class="type">gpointer</span></a> mem</code></em>); |
| <span class="returnvalue">void</span> <a class="link" href="glib-Memory-Chunks.html#g-mem-chunk-destroy" title="g_mem_chunk_destroy ()">g_mem_chunk_destroy</a> (<em class="parameter"><code><a class="link" href="glib-Memory-Chunks.html#GMemChunk" title="GMemChunk"><span class="type">GMemChunk</span></a> *mem_chunk</code></em>); |
| |
| #define <a class="link" href="glib-Memory-Chunks.html#g-mem-chunk-create" title="g_mem_chunk_create()">g_mem_chunk_create</a> (type, |
| pre_alloc, |
| alloc_type) |
| #define <a class="link" href="glib-Memory-Chunks.html#g-chunk-new" title="g_chunk_new()">g_chunk_new</a> (type, |
| chunk) |
| #define <a class="link" href="glib-Memory-Chunks.html#g-chunk-new0" title="g_chunk_new0()">g_chunk_new0</a> (type, |
| chunk) |
| #define <a class="link" href="glib-Memory-Chunks.html#g-chunk-free" title="g_chunk_free()">g_chunk_free</a> (mem, |
| mem_chunk) |
| |
| <span class="returnvalue">void</span> <a class="link" href="glib-Memory-Chunks.html#g-mem-chunk-reset" title="g_mem_chunk_reset ()">g_mem_chunk_reset</a> (<em class="parameter"><code><a class="link" href="glib-Memory-Chunks.html#GMemChunk" title="GMemChunk"><span class="type">GMemChunk</span></a> *mem_chunk</code></em>); |
| <span class="returnvalue">void</span> <a class="link" href="glib-Memory-Chunks.html#g-mem-chunk-clean" title="g_mem_chunk_clean ()">g_mem_chunk_clean</a> (<em class="parameter"><code><a class="link" href="glib-Memory-Chunks.html#GMemChunk" title="GMemChunk"><span class="type">GMemChunk</span></a> *mem_chunk</code></em>); |
| <span class="returnvalue">void</span> <a class="link" href="glib-Memory-Chunks.html#g-blow-chunks" title="g_blow_chunks ()">g_blow_chunks</a> (<em class="parameter"><code><span class="type">void</span></code></em>); |
| |
| <span class="returnvalue">void</span> <a class="link" href="glib-Memory-Chunks.html#g-mem-chunk-info" title="g_mem_chunk_info ()">g_mem_chunk_info</a> (<em class="parameter"><code><span class="type">void</span></code></em>); |
| <span class="returnvalue">void</span> <a class="link" href="glib-Memory-Chunks.html#g-mem-chunk-print" title="g_mem_chunk_print ()">g_mem_chunk_print</a> (<em class="parameter"><code><a class="link" href="glib-Memory-Chunks.html#GMemChunk" title="GMemChunk"><span class="type">GMemChunk</span></a> *mem_chunk</code></em>); |
| </pre> |
| </div> |
| <div class="refsect1" title="Description"> |
| <a name="glib-Memory-Chunks.description"></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 class="link" href="glib-Memory-Chunks.html#G-ALLOC-AND-FREE:CAPS" title="G_ALLOC_AND_FREE"><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 class="link" href="glib-Memory-Allocation.html#g-malloc" title="g_malloc ()"><code class="function">g_malloc()</code></a>. Therefore, memory chunks have been deprecated in |
| favor of the <a class="link" 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 class="link" href="glib-Memory-Chunks.html#G-ALLOC-ONLY:CAPS" title="G_ALLOC_ONLY"><span class="type">G_ALLOC_ONLY</span></a>, and |
| <a class="link" href="glib-Memory-Chunks.html#G-ALLOC-AND-FREE:CAPS" title="G_ALLOC_AND_FREE"><span class="type">G_ALLOC_AND_FREE</span></a>. </p> |
| <div class="itemizedlist"><ul class="itemizedlist" type="disc"> |
| <li class="listitem"><p> <a class="link" href="glib-Memory-Chunks.html#G-ALLOC-ONLY:CAPS" title="G_ALLOC_ONLY"><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 class="listitem"><p> <a class="link" href="glib-Memory-Chunks.html#G-ALLOC-AND-FREE:CAPS" title="G_ALLOC_AND_FREE"><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 class="link" href="glib-Memory-Chunks.html#g-mem-chunk-new" title="g_mem_chunk_new ()"><code class="function">g_mem_chunk_new()</code></a> or the convenience |
| macro <a class="link" href="glib-Memory-Chunks.html#g-mem-chunk-create" title="g_mem_chunk_create()"><code class="function">g_mem_chunk_create()</code></a>. |
| </p> |
| <p> |
| To allocate a new atom use <a class="link" href="glib-Memory-Chunks.html#g-mem-chunk-alloc" title="g_mem_chunk_alloc ()"><code class="function">g_mem_chunk_alloc()</code></a>, |
| <a class="link" href="glib-Memory-Chunks.html#g-mem-chunk-alloc0" title="g_mem_chunk_alloc0 ()"><code class="function">g_mem_chunk_alloc0()</code></a>, or the convenience macros <a class="link" href="glib-Memory-Chunks.html#g-chunk-new" title="g_chunk_new()"><code class="function">g_chunk_new()</code></a> or |
| <a class="link" href="glib-Memory-Chunks.html#g-chunk-new0" title="g_chunk_new0()"><code class="function">g_chunk_new0()</code></a>. |
| </p> |
| <p> |
| To free an atom use <a class="link" href="glib-Memory-Chunks.html#g-mem-chunk-free" title="g_mem_chunk_free ()"><code class="function">g_mem_chunk_free()</code></a>, or the convenience macro |
| <a class="link" href="glib-Memory-Chunks.html#g-chunk-free" title="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 class="link" href="glib-Memory-Chunks.html#G-ALLOC-AND-FREE:CAPS" title="G_ALLOC_AND_FREE"><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 class="link" href="glib-Memory-Chunks.html#g-mem-chunk-clean" title="g_mem_chunk_clean ()"><code class="function">g_mem_chunk_clean()</code></a>. To clean all memory chunks, use <a class="link" href="glib-Memory-Chunks.html#g-blow-chunks" title="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 class="link" href="glib-Memory-Chunks.html#g-mem-chunk-reset" title="g_mem_chunk_reset ()"><code class="function">g_mem_chunk_reset()</code></a>. |
| </p> |
| <p> |
| To destroy a memory chunk, use <a class="link" href="glib-Memory-Chunks.html#g-mem-chunk-destroy" title="g_mem_chunk_destroy ()"><code class="function">g_mem_chunk_destroy()</code></a>. |
| </p> |
| <p> |
| To help debug memory chunks, use <a class="link" href="glib-Memory-Chunks.html#g-mem-chunk-info" title="g_mem_chunk_info ()"><code class="function">g_mem_chunk_info()</code></a> and |
| <a class="link" href="glib-Memory-Chunks.html#g-mem-chunk-print" title="g_mem_chunk_print ()"><code class="function">g_mem_chunk_print()</code></a>. |
| </p> |
| <p> |
| </p> |
| <div class="example"> |
| <a name="id681217"></a><p class="title"><b>Example 17. Using a <a class="link" href="glib-Memory-Chunks.html#GMemChunk" title="GMemChunk"><span class="type">GMemChunk</span></a></b></p> |
| <div class="example-contents"> |
| <table class="listing_frame" border="0" cellpadding="0" cellspacing="0"> |
| <tbody> |
| <tr> |
| <td class="listing_lines" align="right"><pre>1 |
| 2 |
| 3 |
| 4 |
| 5 |
| 6 |
| 7 |
| 8 |
| 9 |
| 10 |
| 11 |
| 12 |
| 13 |
| 14 |
| 15 |
| 16 |
| 17 |
| 18 |
| 19 |
| 20 |
| 21 |
| 22 |
| 23 |
| 24</pre></td> |
| <td class="listing_code"><pre class="programlisting"><span class="normal"><a href="glib-Memory-Chunks.html#GMemChunk">GMemChunk</a> </span><span class="symbol">*</span><span class="normal">mem_chunk</span><span class="symbol">;</span> |
| <span class="normal"><a href="glib-Basic-Types.html#gchar">gchar</a> </span><span class="symbol">*</span><span class="normal">mem</span><span class="symbol">[</span><span class="number">10000</span><span class="symbol">];</span> |
| <span class="normal"><a href="glib-Basic-Types.html#gint">gint</a> i</span><span class="symbol">;</span> |
| |
| <span class="comment">/* Create a GMemChunk with atoms 50 bytes long, and memory</span> |
| <span class="comment"> blocks holding 100 bytes. Note that this means that only 2 atoms</span> |
| <span class="comment"> fit into each memory block and so isn't very efficient. */</span> |
| <span class="normal">mem_chunk </span><span class="symbol">=</span><span class="normal"> </span><span class="function"><a href="glib-Memory-Chunks.html#g-mem-chunk-new">g_mem_chunk_new</a></span><span class="normal"> </span><span class="symbol">(</span><span class="string">"test mem chunk"</span><span class="symbol">,</span><span class="normal"> </span><span class="number">50</span><span class="symbol">,</span><span class="normal"> </span><span class="number">100</span><span class="symbol">,</span><span class="normal"> <a href="glib-Memory-Chunks.html#G-ALLOC-AND-FREE:CAPS">G_ALLOC_AND_FREE</a></span><span class="symbol">);</span> |
| <span class="comment">/* Now allocate 10000 atoms. */</span> |
| <span class="keyword">for</span><span class="normal"> </span><span class="symbol">(</span><span class="normal">i </span><span class="symbol">=</span><span class="normal"> </span><span class="number">0</span><span class="symbol">;</span><span class="normal"> i </span><span class="symbol"><</span><span class="normal"> </span><span class="number">10000</span><span class="symbol">;</span><span class="normal"> i</span><span class="symbol">++)</span> |
| <span class="normal"> </span><span class="cbracket">{</span> |
| <span class="normal"> mem</span><span class="symbol">[</span><span class="normal">i</span><span class="symbol">]</span><span class="normal"> </span><span class="symbol">=</span><span class="normal"> </span><span class="function"><a href="glib-Memory-Chunks.html#g-chunk-new">g_chunk_new</a></span><span class="normal"> </span><span class="symbol">(</span><span class="normal"><a href="glib-Basic-Types.html#gchar">gchar</a></span><span class="symbol">,</span><span class="normal"> mem_chunk</span><span class="symbol">);</span> |
| <span class="normal"> </span><span class="comment">/* Fill in the atom memory with some junk. */</span> |
| <span class="normal"> </span><span class="keyword">for</span><span class="normal"> </span><span class="symbol">(</span><span class="normal">j </span><span class="symbol">=</span><span class="normal"> </span><span class="number">0</span><span class="symbol">;</span><span class="normal"> j </span><span class="symbol"><</span><span class="normal"> </span><span class="number">50</span><span class="symbol">;</span><span class="normal"> j</span><span class="symbol">++)</span> |
| <span class="normal"> mem</span><span class="symbol">[</span><span class="normal">i</span><span class="symbol">][</span><span class="normal">j</span><span class="symbol">]</span><span class="normal"> </span><span class="symbol">=</span><span class="normal"> i </span><span class="symbol">*</span><span class="normal"> j</span><span class="symbol">;</span> |
| <span class="normal"> </span><span class="cbracket">}</span> |
| <span class="comment">/* Now free all of the atoms. Note that since we are going to</span> |
| <span class="comment"> destroy the GMemChunk, this wouldn't normally be used. */</span> |
| <span class="keyword">for</span><span class="normal"> </span><span class="symbol">(</span><span class="normal">i </span><span class="symbol">=</span><span class="normal"> </span><span class="number">0</span><span class="symbol">;</span><span class="normal"> i </span><span class="symbol"><</span><span class="normal"> </span><span class="number">10000</span><span class="symbol">;</span><span class="normal"> i</span><span class="symbol">++)</span> |
| <span class="normal"> </span><span class="cbracket">{</span> |
| <span class="normal"> </span><span class="function"><a href="glib-Memory-Chunks.html#g-mem-chunk-free">g_mem_chunk_free</a></span><span class="normal"> </span><span class="symbol">(</span><span class="normal">mem_chunk</span><span class="symbol">,</span><span class="normal"> mem</span><span class="symbol">[</span><span class="normal">i</span><span class="symbol">]);</span> |
| <span class="normal"> </span><span class="cbracket">}</span> |
| <span class="comment">/* We are finished with the GMemChunk, so we destroy it. */</span> |
| <span class="function"><a href="glib-Memory-Chunks.html#g-mem-chunk-destroy">g_mem_chunk_destroy</a></span><span class="normal"> </span><span class="symbol">(</span><span class="normal">mem_chunk</span><span class="symbol">);</span></pre></td> |
| </tr> |
| </tbody> |
| </table> |
| </div> |
| |
| </div> |
| <p><br class="example-break"> |
| </p> |
| <p> |
| </p> |
| <div class="example"> |
| <a name="id462053"></a><p class="title"><b>Example 18. Using a <a class="link" href="glib-Memory-Chunks.html#GMemChunk" title="GMemChunk"><span class="type">GMemChunk</span></a> with data structures</b></p> |
| <div class="example-contents"> |
| <table class="listing_frame" border="0" cellpadding="0" cellspacing="0"> |
| <tbody> |
| <tr> |
| <td class="listing_lines" align="right"><pre>1 |
| 2 |
| 3 |
| 4 |
| 5 |
| 6 |
| 7 |
| 8 |
| 9 |
| 10 |
| 11 |
| 12 |
| 13 |
| 14 |
| 15 |
| 16 |
| 17 |
| 18 |
| 19</pre></td> |
| <td class="listing_code"><pre class="programlisting"><span class="normal"><a href="glib-Memory-Chunks.html#GMemChunk">GMemChunk</a> </span><span class="symbol">*</span><span class="normal">array_mem_chunk</span><span class="symbol">;</span> |
| <span class="normal">GRealArray </span><span class="symbol">*</span><span class="normal">array</span><span class="symbol">;</span> |
| <span class="comment">/* Create a GMemChunk to hold GRealArray structures, using</span> |
| <span class="comment"> the g_mem_chunk_create() convenience macro. We want 1024 atoms in each</span> |
| <span class="comment"> memory block, and we want to be able to free individual atoms. */</span> |
| <span class="normal">array_mem_chunk </span><span class="symbol">=</span><span class="normal"> </span><span class="function"><a href="glib-Memory-Chunks.html#g-mem-chunk-create">g_mem_chunk_create</a></span><span class="normal"> </span><span class="symbol">(</span><span class="normal">GRealArray</span><span class="symbol">,</span><span class="normal"> </span><span class="number">1024</span><span class="symbol">,</span><span class="normal"> <a href="glib-Memory-Chunks.html#G-ALLOC-AND-FREE:CAPS">G_ALLOC_AND_FREE</a></span><span class="symbol">);</span> |
| <span class="comment">/* Allocate one atom, using the g_chunk_new() convenience macro. */</span> |
| <span class="normal">array </span><span class="symbol">=</span><span class="normal"> </span><span class="function"><a href="glib-Memory-Chunks.html#g-chunk-new">g_chunk_new</a></span><span class="normal"> </span><span class="symbol">(</span><span class="normal">GRealArray</span><span class="symbol">,</span><span class="normal"> array_mem_chunk</span><span class="symbol">);</span> |
| <span class="comment">/* We can now use array just like a normal pointer to a structure. */</span> |
| <span class="normal">array</span><span class="symbol">-></span><span class="normal">data </span><span class="symbol">=</span><span class="normal"> <a href="glib-Standard-Macros.html#NULL:CAPS">NULL</a></span><span class="symbol">;</span> |
| <span class="normal">array</span><span class="symbol">-></span><span class="normal">len </span><span class="symbol">=</span><span class="normal"> </span><span class="number">0</span><span class="symbol">;</span> |
| <span class="normal">array</span><span class="symbol">-></span><span class="normal">alloc </span><span class="symbol">=</span><span class="normal"> </span><span class="number">0</span><span class="symbol">;</span> |
| <span class="normal">array</span><span class="symbol">-></span><span class="normal">zero_terminated </span><span class="symbol">=</span><span class="normal"> </span><span class="symbol">(</span><span class="normal">zero_terminated </span><span class="symbol">?</span><span class="normal"> </span><span class="number">1</span><span class="normal"> </span><span class="symbol">:</span><span class="normal"> </span><span class="number">0</span><span class="symbol">);</span> |
| <span class="normal">array</span><span class="symbol">-></span><span class="normal">clear </span><span class="symbol">=</span><span class="normal"> </span><span class="symbol">(</span><span class="normal">clear </span><span class="symbol">?</span><span class="normal"> </span><span class="number">1</span><span class="normal"> </span><span class="symbol">:</span><span class="normal"> </span><span class="number">0</span><span class="symbol">);</span> |
| <span class="normal">array</span><span class="symbol">-></span><span class="normal">elt_size </span><span class="symbol">=</span><span class="normal"> elt_size</span><span class="symbol">;</span> |
| <span class="comment">/* We can free the element, so it can be reused. */</span> |
| <span class="function"><a href="glib-Memory-Chunks.html#g-chunk-free">g_chunk_free</a></span><span class="normal"> </span><span class="symbol">(</span><span class="normal">array</span><span class="symbol">,</span><span class="normal"> array_mem_chunk</span><span class="symbol">);</span> |
| <span class="comment">/* We destroy the GMemChunk when we are finished with it. */</span> |
| <span class="function"><a href="glib-Memory-Chunks.html#g-mem-chunk-destroy">g_mem_chunk_destroy</a></span><span class="normal"> </span><span class="symbol">(</span><span class="normal">array_mem_chunk</span><span class="symbol">);</span></pre></td> |
| </tr> |
| </tbody> |
| </table> |
| </div> |
| |
| </div> |
| <p><br class="example-break"> |
| </p> |
| </div> |
| <div class="refsect1" title="Details"> |
| <a name="glib-Memory-Chunks.details"></a><h2>Details</h2> |
| <div class="refsect2" title="GMemChunk"> |
| <a name="GMemChunk"></a><h3>GMemChunk</h3> |
| <pre class="programlisting">typedef struct _GMemChunk GMemChunk;</pre> |
| <div class="warning" title="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 class="link" href="glib-Memory-Chunks.html#GMemChunk" title="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" title="G_ALLOC_AND_FREE"> |
| <a name="G-ALLOC-AND-FREE:CAPS"></a><h3>G_ALLOC_AND_FREE</h3> |
| <pre class="programlisting">#define G_ALLOC_AND_FREE 2 |
| </pre> |
| <div class="warning" title="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 class="link" href="glib-Memory-Chunks.html#GMemChunk" title="GMemChunk"><span class="type">GMemChunk</span></a>. Used in <a class="link" href="glib-Memory-Chunks.html#g-mem-chunk-new" title="g_mem_chunk_new ()"><code class="function">g_mem_chunk_new()</code></a> and |
| <a class="link" href="glib-Memory-Chunks.html#g-mem-chunk-create" title="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" title="G_ALLOC_ONLY"> |
| <a name="G-ALLOC-ONLY:CAPS"></a><h3>G_ALLOC_ONLY</h3> |
| <pre class="programlisting">#define G_ALLOC_ONLY 1 |
| </pre> |
| <div class="warning" title="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 class="link" href="glib-Memory-Chunks.html#GMemChunk" title="GMemChunk"><span class="type">GMemChunk</span></a>. Used in <a class="link" href="glib-Memory-Chunks.html#g-mem-chunk-new" title="g_mem_chunk_new ()"><code class="function">g_mem_chunk_new()</code></a> and |
| <a class="link" href="glib-Memory-Chunks.html#g-mem-chunk-create" title="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" title="g_mem_chunk_new ()"> |
| <a name="g-mem-chunk-new"></a><h3>g_mem_chunk_new ()</h3> |
| <pre class="programlisting"><a class="link" href="glib-Memory-Chunks.html#GMemChunk" title="GMemChunk"><span class="returnvalue">GMemChunk</span></a>* g_mem_chunk_new (<em class="parameter"><code>const <a class="link" href="glib-Basic-Types.html#gchar" title="gchar"><span class="type">gchar</span></a> *name</code></em>, |
| <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gint" title="gint"><span class="type">gint</span></a> atom_size</code></em>, |
| <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gsize" title="gsize"><span class="type">gsize</span></a> area_size</code></em>, |
| <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gint" title="gint"><span class="type">gint</span></a> type</code></em>);</pre> |
| <div class="warning" title="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 class="link" href="glib-Memory-Slices.html" title="Memory Slices">slice |
| allocator</a> instead</p> |
| </div> |
| <p> |
| Creates a new <a class="link" href="glib-Memory-Chunks.html#GMemChunk" title="GMemChunk"><span class="type">GMemChunk</span></a>. |
| </p> |
| <div class="variablelist"><table border="0"> |
| <col align="left" valign="top"> |
| <tbody> |
| <tr> |
| <td><p><span class="term"><em class="parameter"><code>name</code></em> :</span></p></td> |
| <td>a string to identify the <a class="link" href="glib-Memory-Chunks.html#GMemChunk" title="GMemChunk"><span class="type">GMemChunk</span></a>. It is not copied so it |
| should be valid for the lifetime of the <a class="link" href="glib-Memory-Chunks.html#GMemChunk" title="GMemChunk"><span class="type">GMemChunk</span></a>. It is |
| only used in <a class="link" href="glib-Memory-Chunks.html#g-mem-chunk-print" title="g_mem_chunk_print ()"><code class="function">g_mem_chunk_print()</code></a>, which is used for debugging. |
| </td> |
| </tr> |
| <tr> |
| <td><p><span class="term"><em class="parameter"><code>atom_size</code></em> :</span></p></td> |
| <td>the size, in bytes, of each element in the <a class="link" href="glib-Memory-Chunks.html#GMemChunk" title="GMemChunk"><span class="type">GMemChunk</span></a>. |
| </td> |
| </tr> |
| <tr> |
| <td><p><span class="term"><em class="parameter"><code>area_size</code></em> :</span></p></td> |
| <td>the size, in bytes, of each block of memory allocated to |
| contain the atoms. |
| </td> |
| </tr> |
| <tr> |
| <td><p><span class="term"><em class="parameter"><code>type</code></em> :</span></p></td> |
| <td>the type of the <a class="link" href="glib-Memory-Chunks.html#GMemChunk" title="GMemChunk"><span class="type">GMemChunk</span></a>. <a class="link" href="glib-Memory-Chunks.html#G-ALLOC-AND-FREE:CAPS" title="G_ALLOC_AND_FREE"><span class="type">G_ALLOC_AND_FREE</span></a> is used if the |
| atoms will be freed individually. <a class="link" href="glib-Memory-Chunks.html#G-ALLOC-ONLY:CAPS" title="G_ALLOC_ONLY"><span class="type">G_ALLOC_ONLY</span></a> should be |
| used if atoms will never be freed individually. |
| <a class="link" href="glib-Memory-Chunks.html#G-ALLOC-ONLY:CAPS" title="G_ALLOC_ONLY"><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><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td> |
| <td>the new <a class="link" href="glib-Memory-Chunks.html#GMemChunk" title="GMemChunk"><span class="type">GMemChunk</span></a>. |
| </td> |
| </tr> |
| </tbody> |
| </table></div> |
| </div> |
| <hr> |
| <div class="refsect2" title="g_mem_chunk_alloc ()"> |
| <a name="g-mem-chunk-alloc"></a><h3>g_mem_chunk_alloc ()</h3> |
| <pre class="programlisting"><a class="link" href="glib-Basic-Types.html#gpointer" title="gpointer"><span class="returnvalue">gpointer</span></a> g_mem_chunk_alloc (<em class="parameter"><code><a class="link" href="glib-Memory-Chunks.html#GMemChunk" title="GMemChunk"><span class="type">GMemChunk</span></a> *mem_chunk</code></em>);</pre> |
| <div class="warning" title="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 class="link" href="glib-Memory-Slices.html#g-slice-alloc" title="g_slice_alloc ()"><code class="function">g_slice_alloc()</code></a> instead</p> |
| </div> |
| <p> |
| Allocates an atom of memory from a <a class="link" href="glib-Memory-Chunks.html#GMemChunk" title="GMemChunk"><span class="type">GMemChunk</span></a>. |
| </p> |
| <div class="variablelist"><table border="0"> |
| <col align="left" valign="top"> |
| <tbody> |
| <tr> |
| <td><p><span class="term"><em class="parameter"><code>mem_chunk</code></em> :</span></p></td> |
| <td>a <a class="link" href="glib-Memory-Chunks.html#GMemChunk" title="GMemChunk"><span class="type">GMemChunk</span></a>. |
| </td> |
| </tr> |
| <tr> |
| <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td> |
| <td>a pointer to the allocated atom. |
| </td> |
| </tr> |
| </tbody> |
| </table></div> |
| </div> |
| <hr> |
| <div class="refsect2" title="g_mem_chunk_alloc0 ()"> |
| <a name="g-mem-chunk-alloc0"></a><h3>g_mem_chunk_alloc0 ()</h3> |
| <pre class="programlisting"><a class="link" href="glib-Basic-Types.html#gpointer" title="gpointer"><span class="returnvalue">gpointer</span></a> g_mem_chunk_alloc0 (<em class="parameter"><code><a class="link" href="glib-Memory-Chunks.html#GMemChunk" title="GMemChunk"><span class="type">GMemChunk</span></a> *mem_chunk</code></em>);</pre> |
| <div class="warning" title="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 class="link" href="glib-Memory-Slices.html#g-slice-alloc0" title="g_slice_alloc0 ()"><code class="function">g_slice_alloc0()</code></a> instead</p> |
| </div> |
| <p> |
| Allocates an atom of memory from a <a class="link" href="glib-Memory-Chunks.html#GMemChunk" title="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><p><span class="term"><em class="parameter"><code>mem_chunk</code></em> :</span></p></td> |
| <td>a <a class="link" href="glib-Memory-Chunks.html#GMemChunk" title="GMemChunk"><span class="type">GMemChunk</span></a>. |
| </td> |
| </tr> |
| <tr> |
| <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td> |
| <td>a pointer to the allocated atom. |
| </td> |
| </tr> |
| </tbody> |
| </table></div> |
| </div> |
| <hr> |
| <div class="refsect2" title="g_mem_chunk_free ()"> |
| <a name="g-mem-chunk-free"></a><h3>g_mem_chunk_free ()</h3> |
| <pre class="programlisting"><span class="returnvalue">void</span> g_mem_chunk_free (<em class="parameter"><code><a class="link" href="glib-Memory-Chunks.html#GMemChunk" title="GMemChunk"><span class="type">GMemChunk</span></a> *mem_chunk</code></em>, |
| <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gpointer" title="gpointer"><span class="type">gpointer</span></a> mem</code></em>);</pre> |
| <div class="warning" title="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 class="link" href="glib-Memory-Slices.html#g-slice-free1" title="g_slice_free1 ()"><code class="function">g_slice_free1()</code></a> instead</p> |
| </div> |
| <p> |
| Frees an atom in a <a class="link" href="glib-Memory-Chunks.html#GMemChunk" title="GMemChunk"><span class="type">GMemChunk</span></a>. This should only be called if the |
| <a class="link" href="glib-Memory-Chunks.html#GMemChunk" title="GMemChunk"><span class="type">GMemChunk</span></a> was created with <a class="link" href="glib-Memory-Chunks.html#G-ALLOC-AND-FREE:CAPS" title="G_ALLOC_AND_FREE"><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><p><span class="term"><em class="parameter"><code>mem_chunk</code></em> :</span></p></td> |
| <td>a <a class="link" href="glib-Memory-Chunks.html#GMemChunk" title="GMemChunk"><span class="type">GMemChunk</span></a>. |
| </td> |
| </tr> |
| <tr> |
| <td><p><span class="term"><em class="parameter"><code>mem</code></em> :</span></p></td> |
| <td>a pointer to the atom to free. |
| </td> |
| </tr> |
| </tbody> |
| </table></div> |
| </div> |
| <hr> |
| <div class="refsect2" title="g_mem_chunk_destroy ()"> |
| <a name="g-mem-chunk-destroy"></a><h3>g_mem_chunk_destroy ()</h3> |
| <pre class="programlisting"><span class="returnvalue">void</span> g_mem_chunk_destroy (<em class="parameter"><code><a class="link" href="glib-Memory-Chunks.html#GMemChunk" title="GMemChunk"><span class="type">GMemChunk</span></a> *mem_chunk</code></em>);</pre> |
| <div class="warning" title="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 class="link" href="glib-Memory-Slices.html" title="Memory Slices">slice |
| allocator</a> instead</p> |
| </div> |
| <p> |
| Frees all of the memory allocated for a <a class="link" href="glib-Memory-Chunks.html#GMemChunk" title="GMemChunk"><span class="type">GMemChunk</span></a>. |
| </p> |
| <div class="variablelist"><table border="0"> |
| <col align="left" valign="top"> |
| <tbody><tr> |
| <td><p><span class="term"><em class="parameter"><code>mem_chunk</code></em> :</span></p></td> |
| <td>a <a class="link" href="glib-Memory-Chunks.html#GMemChunk" title="GMemChunk"><span class="type">GMemChunk</span></a>. |
| </td> |
| </tr></tbody> |
| </table></div> |
| </div> |
| <hr> |
| <div class="refsect2" title="g_mem_chunk_create()"> |
| <a name="g-mem-chunk-create"></a><h3>g_mem_chunk_create()</h3> |
| <pre class="programlisting">#define g_mem_chunk_create(type, pre_alloc, alloc_type)</pre> |
| <div class="warning" title="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 class="link" href="glib-Memory-Slices.html" title="Memory Slices">slice |
| allocator</a> instead</p> |
| </div> |
| <p> |
| A convenience macro for creating a new <a class="link" href="glib-Memory-Chunks.html#GMemChunk" title="GMemChunk"><span class="type">GMemChunk</span></a>. It calls |
| <a class="link" href="glib-Memory-Chunks.html#g-mem-chunk-new" title="g_mem_chunk_new ()"><code class="function">g_mem_chunk_new()</code></a>, using the given type to create the <a class="link" href="glib-Memory-Chunks.html#GMemChunk" title="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><p><span class="term"><em class="parameter"><code>type</code></em> :</span></p></td> |
| <td>the type of the atoms, typically a structure name. |
| </td> |
| </tr> |
| <tr> |
| <td><p><span class="term"><em class="parameter"><code>pre_alloc</code></em> :</span></p></td> |
| <td>the number of atoms to store in each block of memory. |
| </td> |
| </tr> |
| <tr> |
| <td><p><span class="term"><em class="parameter"><code>alloc_type</code></em> :</span></p></td> |
| <td>the type of the <a class="link" href="glib-Memory-Chunks.html#GMemChunk" title="GMemChunk"><span class="type">GMemChunk</span></a>. <a class="link" href="glib-Memory-Chunks.html#G-ALLOC-AND-FREE:CAPS" title="G_ALLOC_AND_FREE"><span class="type">G_ALLOC_AND_FREE</span></a> is used |
| if the atoms will be freed individually. <a class="link" href="glib-Memory-Chunks.html#G-ALLOC-ONLY:CAPS" title="G_ALLOC_ONLY"><span class="type">G_ALLOC_ONLY</span></a> |
| should be used if atoms will never be freed |
| individually. <a class="link" href="glib-Memory-Chunks.html#G-ALLOC-ONLY:CAPS" title="G_ALLOC_ONLY"><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><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td> |
| <td>the new <a class="link" href="glib-Memory-Chunks.html#GMemChunk" title="GMemChunk"><span class="type">GMemChunk</span></a>. |
| </td> |
| </tr> |
| </tbody> |
| </table></div> |
| </div> |
| <hr> |
| <div class="refsect2" title="g_chunk_new()"> |
| <a name="g-chunk-new"></a><h3>g_chunk_new()</h3> |
| <pre class="programlisting">#define g_chunk_new(type, chunk)</pre> |
| <div class="warning" title="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 class="link" href="glib-Memory-Slices.html#g-slice-new" title="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 class="link" href="glib-Memory-Chunks.html#GMemChunk" title="GMemChunk"><span class="type">GMemChunk</span></a>. |
| It calls <a class="link" href="glib-Memory-Chunks.html#g-mem-chunk-alloc" title="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><p><span class="term"><em class="parameter"><code>type</code></em> :</span></p></td> |
| <td>the type of the <a class="link" href="glib-Memory-Chunks.html#GMemChunk" title="GMemChunk"><span class="type">GMemChunk</span></a> atoms, typically a structure name. |
| </td> |
| </tr> |
| <tr> |
| <td><p><span class="term"><em class="parameter"><code>chunk</code></em> :</span></p></td> |
| <td>a <a class="link" href="glib-Memory-Chunks.html#GMemChunk" title="GMemChunk"><span class="type">GMemChunk</span></a>. |
| </td> |
| </tr> |
| <tr> |
| <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></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" title="g_chunk_new0()"> |
| <a name="g-chunk-new0"></a><h3>g_chunk_new0()</h3> |
| <pre class="programlisting">#define g_chunk_new0(type, chunk)</pre> |
| <div class="warning" title="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 class="link" href="glib-Memory-Slices.html#g-slice-new0" title="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 class="link" href="glib-Memory-Chunks.html#GMemChunk" title="GMemChunk"><span class="type">GMemChunk</span></a>. |
| It calls <a class="link" href="glib-Memory-Chunks.html#g-mem-chunk-alloc0" title="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><p><span class="term"><em class="parameter"><code>type</code></em> :</span></p></td> |
| <td>the type of the <a class="link" href="glib-Memory-Chunks.html#GMemChunk" title="GMemChunk"><span class="type">GMemChunk</span></a> atoms, typically a structure name. |
| </td> |
| </tr> |
| <tr> |
| <td><p><span class="term"><em class="parameter"><code>chunk</code></em> :</span></p></td> |
| <td>a <a class="link" href="glib-Memory-Chunks.html#GMemChunk" title="GMemChunk"><span class="type">GMemChunk</span></a>. |
| </td> |
| </tr> |
| <tr> |
| <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></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" title="g_chunk_free()"> |
| <a name="g-chunk-free"></a><h3>g_chunk_free()</h3> |
| <pre class="programlisting">#define g_chunk_free(mem, mem_chunk)</pre> |
| <div class="warning" title="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 class="link" href="glib-Memory-Slices.html#g-slice-free" title="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 class="link" href="glib-Memory-Chunks.html#GMemChunk" title="GMemChunk"><span class="type">GMemChunk</span></a>. It |
| simply switches the arguments and calls <a class="link" href="glib-Memory-Chunks.html#g-mem-chunk-free" title="g_mem_chunk_free ()"><code class="function">g_mem_chunk_free()</code></a> It is |
| included simply to complement the other convenience macros, |
| <a class="link" href="glib-Memory-Chunks.html#g-chunk-new" title="g_chunk_new()"><code class="function">g_chunk_new()</code></a> and <a class="link" href="glib-Memory-Chunks.html#g-chunk-new0" title="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><p><span class="term"><em class="parameter"><code>mem</code></em> :</span></p></td> |
| <td>a pointer to the atom to be freed. |
| </td> |
| </tr> |
| <tr> |
| <td><p><span class="term"><em class="parameter"><code>mem_chunk</code></em> :</span></p></td> |
| <td>a <a class="link" href="glib-Memory-Chunks.html#GMemChunk" title="GMemChunk"><span class="type">GMemChunk</span></a>. |
| </td> |
| </tr> |
| </tbody> |
| </table></div> |
| </div> |
| <hr> |
| <div class="refsect2" title="g_mem_chunk_reset ()"> |
| <a name="g-mem-chunk-reset"></a><h3>g_mem_chunk_reset ()</h3> |
| <pre class="programlisting"><span class="returnvalue">void</span> g_mem_chunk_reset (<em class="parameter"><code><a class="link" href="glib-Memory-Chunks.html#GMemChunk" title="GMemChunk"><span class="type">GMemChunk</span></a> *mem_chunk</code></em>);</pre> |
| <div class="warning" title="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 class="link" 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><p><span class="term"><em class="parameter"><code>mem_chunk</code></em> :</span></p></td> |
| <td>a <a class="link" href="glib-Memory-Chunks.html#GMemChunk" title="GMemChunk"><span class="type">GMemChunk</span></a>. |
| </td> |
| </tr></tbody> |
| </table></div> |
| </div> |
| <hr> |
| <div class="refsect2" title="g_mem_chunk_clean ()"> |
| <a name="g-mem-chunk-clean"></a><h3>g_mem_chunk_clean ()</h3> |
| <pre class="programlisting"><span class="returnvalue">void</span> g_mem_chunk_clean (<em class="parameter"><code><a class="link" href="glib-Memory-Chunks.html#GMemChunk" title="GMemChunk"><span class="type">GMemChunk</span></a> *mem_chunk</code></em>);</pre> |
| <div class="warning" title="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 class="link" href="glib-Memory-Slices.html" title="Memory Slices">slice |
| allocator</a> instead</p> |
| </div> |
| <p> |
| Frees any blocks in a <a class="link" href="glib-Memory-Chunks.html#GMemChunk" title="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><p><span class="term"><em class="parameter"><code>mem_chunk</code></em> :</span></p></td> |
| <td>a <a class="link" href="glib-Memory-Chunks.html#GMemChunk" title="GMemChunk"><span class="type">GMemChunk</span></a>. |
| </td> |
| </tr></tbody> |
| </table></div> |
| </div> |
| <hr> |
| <div class="refsect2" title="g_blow_chunks ()"> |
| <a name="g-blow-chunks"></a><h3>g_blow_chunks ()</h3> |
| <pre class="programlisting"><span class="returnvalue">void</span> g_blow_chunks (<em class="parameter"><code><span class="type">void</span></code></em>);</pre> |
| <div class="warning" title="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 class="link" href="glib-Memory-Slices.html" title="Memory Slices">slice |
| allocator</a> instead</p> |
| </div> |
| <p> |
| Calls <a class="link" href="glib-Memory-Chunks.html#g-mem-chunk-clean" title="g_mem_chunk_clean ()"><code class="function">g_mem_chunk_clean()</code></a> on all <a class="link" href="glib-Memory-Chunks.html#GMemChunk" title="GMemChunk"><span class="type">GMemChunk</span></a> objects. |
| </p> |
| </div> |
| <hr> |
| <div class="refsect2" title="g_mem_chunk_info ()"> |
| <a name="g-mem-chunk-info"></a><h3>g_mem_chunk_info ()</h3> |
| <pre class="programlisting"><span class="returnvalue">void</span> g_mem_chunk_info (<em class="parameter"><code><span class="type">void</span></code></em>);</pre> |
| <div class="warning" title="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 class="link" href="glib-Memory-Slices.html" title="Memory Slices">slice |
| allocator</a> instead</p> |
| </div> |
| <p> |
| Outputs debugging information for all <a class="link" href="glib-Memory-Chunks.html#GMemChunk" title="GMemChunk"><span class="type">GMemChunk</span></a> objects currently |
| in use. It outputs the number of <a class="link" href="glib-Memory-Chunks.html#GMemChunk" title="GMemChunk"><span class="type">GMemChunk</span></a> objects currently |
| allocated, and calls <a class="link" href="glib-Memory-Chunks.html#g-mem-chunk-print" title="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" title="g_mem_chunk_print ()"> |
| <a name="g-mem-chunk-print"></a><h3>g_mem_chunk_print ()</h3> |
| <pre class="programlisting"><span class="returnvalue">void</span> g_mem_chunk_print (<em class="parameter"><code><a class="link" href="glib-Memory-Chunks.html#GMemChunk" title="GMemChunk"><span class="type">GMemChunk</span></a> *mem_chunk</code></em>);</pre> |
| <div class="warning" title="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 class="link" href="glib-Memory-Slices.html" title="Memory Slices">slice |
| allocator</a> instead</p> |
| </div> |
| <p> |
| Outputs debugging information for a <a class="link" href="glib-Memory-Chunks.html#GMemChunk" title="GMemChunk"><span class="type">GMemChunk</span></a>. It outputs the name |
| of the <a class="link" href="glib-Memory-Chunks.html#GMemChunk" title="GMemChunk"><span class="type">GMemChunk</span></a> (set with <a class="link" href="glib-Memory-Chunks.html#g-mem-chunk-new" title="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><p><span class="term"><em class="parameter"><code>mem_chunk</code></em> :</span></p></td> |
| <td>a <a class="link" href="glib-Memory-Chunks.html#GMemChunk" title="GMemChunk"><span class="type">GMemChunk</span></a>. |
| </td> |
| </tr></tbody> |
| </table></div> |
| </div> |
| </div> |
| </div> |
| <div class="footer"> |
| <hr> |
| Generated by GTK-Doc V1.14</div> |
| </body> |
| </html> |