📄 glib-memory-chunks.html
字号:
</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="id3101799"></a><h3><a name="g-mem-chunk-free"></a>g_mem_chunk_free ()</h3><a class="indexterm" name="id3101810"></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><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="id3101912"></a><h3><a name="g-mem-chunk-destroy"></a>g_mem_chunk_destroy ()</h3><a class="indexterm" name="id3101923"></a><pre class="programlisting">void g_mem_chunk_destroy (<a href="glib-Memory-Chunks.html#GMemChunk">GMemChunk</a> *mem_chunk);</pre><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="id3101985"></a><h3><a name="g-mem-chunk-create"></a>g_mem_chunk_create()</h3><a class="indexterm" name="id3101996"></a><pre class="programlisting">#define g_mem_chunk_create(type, pre_alloc, alloc_type)</pre><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 thearea size is calculated by multiplying the <em class="parameter"><code>pre_alloc</code></em> parameter withthe 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="id3102164"></a><h3><a name="g-chunk-new"></a>g_chunk_new()</h3><a class="indexterm" name="id3102174"></a><pre class="programlisting">#define g_chunk_new(type, chunk)</pre><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 tothe 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="id3102276"></a><h3><a name="g-chunk-new0"></a>g_chunk_new0()</h3><a class="indexterm" name="id3102286"></a><pre class="programlisting">#define g_chunk_new0(type, chunk)</pre><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 tothe 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="id3102388"></a><h3><a name="g-chunk-free"></a>g_chunk_free()</h3><a class="indexterm" name="id3102398"></a><pre class="programlisting">#define g_chunk_free(mem, mem_chunk)</pre><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="id3102495"></a><h3><a name="g-mem-chunk-reset"></a>g_mem_chunk_reset ()</h3><a class="indexterm" name="id3102506"></a><pre class="programlisting">void g_mem_chunk_reset (<a href="glib-Memory-Chunks.html#GMemChunk">GMemChunk</a> *mem_chunk);</pre><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="id3102561"></a><h3><a name="g-mem-chunk-clean"></a>g_mem_chunk_clean ()</h3><a class="indexterm" name="id3102572"></a><pre class="programlisting">void g_mem_chunk_clean (<a href="glib-Memory-Chunks.html#GMemChunk">GMemChunk</a> *mem_chunk);</pre><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="id3102635"></a><h3><a name="g-blow-chunks"></a>g_blow_chunks ()</h3><a class="indexterm" name="id3102645"></a><pre class="programlisting">void g_blow_chunks (void);</pre><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="id3102685"></a><h3><a name="g-mem-chunk-info"></a>g_mem_chunk_info ()</h3><a class="indexterm" name="id3102695"></a><pre class="programlisting">void g_mem_chunk_info (void);</pre><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="id3102746"></a><h3><a name="g-mem-chunk-print"></a>g_mem_chunk_print ()</h3><a class="indexterm" name="id3102756"></a><pre class="programlisting">void g_mem_chunk_print (<a href="glib-Memory-Chunks.html#GMemChunk">GMemChunk</a> *mem_chunk);</pre><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><table class="navigation" width="100%" summary="Navigation footer" cellpadding="2" cellspacing="0"><tr valign="middle"><td align="left"><a accesskey="p" href="glib-data-types.html"><b><< GLib Data Types</b></a></td><td align="right"><a accesskey="n" href="glib-Doubly-Linked-Lists.html"><b>Doubly-Linked Lists >></b></a></td></tr></table></body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -