| Current File : //usr/share/doc/dbus/api/group__DBusMemPool.html |
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<title>D-Bus: memory pools</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
<tbody>
<tr style="height: 56px;">
<td style="padding-left: 0.5em;">
<div id="projectname">D-Bus
 <span id="projectnumber">1.8.20</span>
</div>
</td>
</tr>
</tbody>
</table>
</div>
<!-- Generated by Doxygen 1.7.6.1 -->
<div id="navrow1" class="tabs">
<ul class="tablist">
<li><a href="index.html"><span>Main Page</span></a></li>
<li><a href="pages.html"><span>Related Pages</span></a></li>
<li><a href="modules.html"><span>Modules</span></a></li>
<li><a href="annotated.html"><span>Data Structures</span></a></li>
<li><a href="files.html"><span>Files</span></a></li>
</ul>
</div>
</div>
<div class="header">
<div class="summary">
<a href="#typedef-members">Typedefs</a> |
<a href="#func-members">Functions</a> </div>
<div class="headertitle">
<div class="title">memory pools</div> </div>
<div class="ingroups"><a class="el" href="group__DBusInternals.html">D-Bus secret internal implementation details</a></div></div><!--header-->
<div class="contents">
<p><a class="el" href="structDBusMemPool.html" title="Internals fields of DBusMemPool.">DBusMemPool</a> object.
<a href="#details">More...</a></p>
<table class="memberdecls">
<tr><td colspan="2"><h2><a name="typedef-members"></a>
Typedefs</h2></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">typedef struct <a class="el" href="structDBusMemPool.html">DBusMemPool</a> </td><td class="memItemRight" valign="bottom"><a class="el" href="group__DBusMemPool.html#gaadb50c95482bc5d2808e190c5618065c">DBusMemPool</a></td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">Opaque object representing a memory pool. <a href="#gaadb50c95482bc5d2808e190c5618065c"></a><br/></td></tr>
<tr><td colspan="2"><h2><a name="func-members"></a>
Functions</h2></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="el" href="structDBusMemPool.html">DBusMemPool</a> * </td><td class="memItemRight" valign="bottom"><a class="el" href="group__DBusMemPool.html#gaf1bae02bc5fcb879f77ff2c13ca03ac8">_dbus_mem_pool_new</a> (int element_size, <a class="el" href="group__DBusTypes.html#ga39c9cb0f3a2a8ad6f55cc4855d035349">dbus_bool_t</a> zero_elements)</td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">Creates a new memory pool, or returns <a class="el" href="group__DBusMacros.html#ga070d2ce7b6bb7e5c05602aa8c308d0c4" title="A null pointer, defined appropriately for C or C++.">NULL</a> on failure. <a href="#gaf1bae02bc5fcb879f77ff2c13ca03ac8"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="group__DBusMemPool.html#ga58e4f3def46410d5bb138a2b8f366b1a">_dbus_mem_pool_free</a> (<a class="el" href="structDBusMemPool.html">DBusMemPool</a> *pool)</td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">Frees a memory pool (and all elements allocated from it). <a href="#ga58e4f3def46410d5bb138a2b8f366b1a"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">void * </td><td class="memItemRight" valign="bottom"><a class="el" href="group__DBusMemPool.html#ga0946d54f767b4f55238f5a39c8543df1">_dbus_mem_pool_alloc</a> (<a class="el" href="structDBusMemPool.html">DBusMemPool</a> *pool)</td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">Allocates an object from the memory pool. <a href="#ga0946d54f767b4f55238f5a39c8543df1"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="el" href="group__DBusTypes.html#ga39c9cb0f3a2a8ad6f55cc4855d035349">dbus_bool_t</a> </td><td class="memItemRight" valign="bottom"><a class="el" href="group__DBusMemPool.html#ga4e2feaefee7384ed940059e6c7b0a9d5">_dbus_mem_pool_dealloc</a> (<a class="el" href="structDBusMemPool.html">DBusMemPool</a> *pool, void *element)</td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">Deallocates an object previously created with <a class="el" href="group__DBusMemPool.html#ga0946d54f767b4f55238f5a39c8543df1" title="Allocates an object from the memory pool.">_dbus_mem_pool_alloc()</a>. <a href="#ga4e2feaefee7384ed940059e6c7b0a9d5"></a><br/></td></tr>
</table>
<hr/><a name="details" id="details"></a><h2>Detailed Description</h2>
<p><a class="el" href="structDBusMemPool.html" title="Internals fields of DBusMemPool.">DBusMemPool</a> object. </p>
<p>Types and functions related to <a class="el" href="structDBusMemPool.html" title="Internals fields of DBusMemPool.">DBusMemPool</a>. A memory pool is used to decrease memory fragmentation/overhead and increase speed for blocks of small uniformly-sized objects. The main point is to avoid the overhead of a malloc block for each small object, speed is secondary. </p>
<hr/><h2>Typedef Documentation</h2>
<a class="anchor" id="gaadb50c95482bc5d2808e190c5618065c"></a><!-- doxytag: member="dbus-mempool.h::DBusMemPool" ref="gaadb50c95482bc5d2808e190c5618065c" args="" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname"><a class="el" href="structDBusMemPool.html">DBusMemPool</a></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>Opaque object representing a memory pool. </p>
<p>Memory pools allow avoiding per-malloc-block memory overhead when allocating a lot of small objects that are all the same size. They are slightly faster than calling malloc() also. </p>
<p>Definition at line <a class="el" href="dbus-mempool_8h_source.html#l00033">33</a> of file <a class="el" href="dbus-mempool_8h_source.html">dbus-mempool.h</a>.</p>
</div>
</div>
<hr/><h2>Function Documentation</h2>
<a class="anchor" id="ga0946d54f767b4f55238f5a39c8543df1"></a><!-- doxytag: member="dbus-mempool.c::_dbus_mem_pool_alloc" ref="ga0946d54f767b4f55238f5a39c8543df1" args="(DBusMemPool *pool)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void* <a class="el" href="group__DBusMemPool.html#ga0946d54f767b4f55238f5a39c8543df1">_dbus_mem_pool_alloc</a> </td>
<td>(</td>
<td class="paramtype"><a class="el" href="structDBusMemPool.html">DBusMemPool</a> * </td>
<td class="paramname"><em>pool</em></td><td>)</td>
<td></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>Allocates an object from the memory pool. </p>
<p>The object must be freed with <a class="el" href="group__DBusMemPool.html#ga4e2feaefee7384ed940059e6c7b0a9d5" title="Deallocates an object previously created with _dbus_mem_pool_alloc().">_dbus_mem_pool_dealloc()</a>.</p>
<dl class="params"><dt><b>Parameters:</b></dt><dd>
<table class="params">
<tr><td class="paramname">pool</td><td>the memory pool </td></tr>
</table>
</dd>
</dl>
<dl class="return"><dt><b>Returns:</b></dt><dd>the allocated object or <a class="el" href="group__DBusMacros.html#ga070d2ce7b6bb7e5c05602aa8c308d0c4" title="A null pointer, defined appropriately for C or C++.">NULL</a> if no memory. </dd></dl>
<p>Definition at line <a class="el" href="dbus-mempool_8c_source.html#l00214">214</a> of file <a class="el" href="dbus-mempool_8c_source.html">dbus-mempool.c</a>.</p>
<p>References <a class="el" href="dbus-mempool_8c_source.html#l00106">allocated_elements</a>, <a class="el" href="dbus-mempool_8c_source.html#l00101">block_size</a>, <a class="el" href="dbus-mempool_8c_source.html#l00105">blocks</a>, <a class="el" href="dbus-memory_8c_source.html#l00461">dbus_malloc()</a>, <a class="el" href="dbus-memory_8c_source.html#l00531">dbus_malloc0()</a>, <a class="el" href="dbus-mempool_8c_source.html#l00070">ELEMENT_PADDING</a>, <a class="el" href="dbus-mempool_8c_source.html#l00100">element_size</a>, <a class="el" href="dbus-mempool_8c_source.html#l00092">DBusMemBlock::elements</a>, <a class="el" href="dbus-mempool_8c_source.html#l00104">free_elements</a>, <a class="el" href="dbus-mempool_8c_source.html#l00063">DBusFreedElement::next</a>, <a class="el" href="dbus-mempool_8c_source.html#l00084">DBusMemBlock::next</a>, <a class="el" href="group__DBusMacros.html#ga070d2ce7b6bb7e5c05602aa8c308d0c4">NULL</a>, <a class="el" href="dbus-mempool_8c_source.html#l00090">DBusMemBlock::used_so_far</a>, and <a class="el" href="dbus-mempool_8c_source.html#l00102">zero_elements</a>.</p>
</div>
</div>
<a class="anchor" id="ga4e2feaefee7384ed940059e6c7b0a9d5"></a><!-- doxytag: member="dbus-mempool.c::_dbus_mem_pool_dealloc" ref="ga4e2feaefee7384ed940059e6c7b0a9d5" args="(DBusMemPool *pool, void *element)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname"><a class="el" href="group__DBusTypes.html#ga39c9cb0f3a2a8ad6f55cc4855d035349">dbus_bool_t</a> <a class="el" href="group__DBusMemPool.html#ga4e2feaefee7384ed940059e6c7b0a9d5">_dbus_mem_pool_dealloc</a> </td>
<td>(</td>
<td class="paramtype"><a class="el" href="structDBusMemPool.html">DBusMemPool</a> * </td>
<td class="paramname"><em>pool</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">void * </td>
<td class="paramname"><em>element</em> </td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>Deallocates an object previously created with <a class="el" href="group__DBusMemPool.html#ga0946d54f767b4f55238f5a39c8543df1" title="Allocates an object from the memory pool.">_dbus_mem_pool_alloc()</a>. </p>
<p>The previous object must have come from this same pool. </p>
<dl class="params"><dt><b>Parameters:</b></dt><dd>
<table class="params">
<tr><td class="paramname">pool</td><td>the memory pool </td></tr>
<tr><td class="paramname">element</td><td>the element earlier allocated. </td></tr>
</table>
</dd>
</dl>
<dl class="return"><dt><b>Returns:</b></dt><dd><a class="el" href="group__DBusMacros.html#gaa8cecfc5c5c054d2875c03e77b7be15d" title="Expands to "1".">TRUE</a> if there are no remaining allocated elements </dd></dl>
<p>Definition at line <a class="el" href="dbus-mempool_8c_source.html#l00347">347</a> of file <a class="el" href="dbus-mempool_8c_source.html">dbus-mempool.c</a>.</p>
<p>References <a class="el" href="dbus-mempool_8c_source.html#l00106">allocated_elements</a>, <a class="el" href="dbus-mempool_8c_source.html#l00105">blocks</a>, <a class="el" href="dbus-memory_8c_source.html#l00701">dbus_free()</a>, <a class="el" href="dbus-mempool_8c_source.html#l00092">DBusMemBlock::elements</a>, <a class="el" href="group__DBusMacros.html#gaa93f0eb578d23995850d61f7d61c55c1">FALSE</a>, <a class="el" href="dbus-mempool_8c_source.html#l00104">free_elements</a>, <a class="el" href="dbus-mempool_8c_source.html#l00063">DBusFreedElement::next</a>, <a class="el" href="dbus-mempool_8c_source.html#l00084">DBusMemBlock::next</a>, and <a class="el" href="group__DBusMacros.html#ga070d2ce7b6bb7e5c05602aa8c308d0c4">NULL</a>.</p>
<p>Referenced by <a class="el" href="dbus-hash_8c_source.html#l01339">_dbus_hash_table_free_preallocated_entry()</a>.</p>
</div>
</div>
<a class="anchor" id="ga58e4f3def46410d5bb138a2b8f366b1a"></a><!-- doxytag: member="dbus-mempool.c::_dbus_mem_pool_free" ref="ga58e4f3def46410d5bb138a2b8f366b1a" args="(DBusMemPool *pool)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void <a class="el" href="group__DBusMemPool.html#ga58e4f3def46410d5bb138a2b8f366b1a">_dbus_mem_pool_free</a> </td>
<td>(</td>
<td class="paramtype"><a class="el" href="structDBusMemPool.html">DBusMemPool</a> * </td>
<td class="paramname"><em>pool</em></td><td>)</td>
<td></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>Frees a memory pool (and all elements allocated from it). </p>
<dl class="params"><dt><b>Parameters:</b></dt><dd>
<table class="params">
<tr><td class="paramname">pool</td><td>the memory pool. </td></tr>
</table>
</dd>
</dl>
<p>Definition at line <a class="el" href="dbus-mempool_8c_source.html#l00187">187</a> of file <a class="el" href="dbus-mempool_8c_source.html">dbus-mempool.c</a>.</p>
<p>References <a class="el" href="dbus-mempool_8c_source.html#l00105">blocks</a>, <a class="el" href="dbus-memory_8c_source.html#l00701">dbus_free()</a>, <a class="el" href="dbus-mempool_8c_source.html#l00084">DBusMemBlock::next</a>, and <a class="el" href="group__DBusMacros.html#ga070d2ce7b6bb7e5c05602aa8c308d0c4">NULL</a>.</p>
<p>Referenced by <a class="el" href="dbus-hash_8c_source.html#l00361">_dbus_hash_table_unref()</a>.</p>
</div>
</div>
<a class="anchor" id="gaf1bae02bc5fcb879f77ff2c13ca03ac8"></a><!-- doxytag: member="dbus-mempool.c::_dbus_mem_pool_new" ref="gaf1bae02bc5fcb879f77ff2c13ca03ac8" args="(int element_size, dbus_bool_t zero_elements)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname"><a class="el" href="structDBusMemPool.html">DBusMemPool</a>* <a class="el" href="group__DBusMemPool.html#gaf1bae02bc5fcb879f77ff2c13ca03ac8">_dbus_mem_pool_new</a> </td>
<td>(</td>
<td class="paramtype">int </td>
<td class="paramname"><em>element_size</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype"><a class="el" href="group__DBusTypes.html#ga39c9cb0f3a2a8ad6f55cc4855d035349">dbus_bool_t</a> </td>
<td class="paramname"><em>zero_elements</em> </td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>Creates a new memory pool, or returns <a class="el" href="group__DBusMacros.html#ga070d2ce7b6bb7e5c05602aa8c308d0c4" title="A null pointer, defined appropriately for C or C++.">NULL</a> on failure. </p>
<p>Objects in the pool must be at least sizeof(void*) bytes each, due to the way memory pools work. To avoid creating 64 bit problems, this means at least 8 bytes on all platforms, unless you are 4 bytes on 32-bit and 8 bytes on 64-bit.</p>
<dl class="params"><dt><b>Parameters:</b></dt><dd>
<table class="params">
<tr><td class="paramname">element_size</td><td>size of an element allocated from the pool. </td></tr>
<tr><td class="paramname">zero_elements</td><td>whether to zero-initialize elements </td></tr>
</table>
</dd>
</dl>
<dl class="return"><dt><b>Returns:</b></dt><dd>the new pool or <a class="el" href="group__DBusMacros.html#ga070d2ce7b6bb7e5c05602aa8c308d0c4" title="A null pointer, defined appropriately for C or C++.">NULL</a> </dd></dl>
<p>Definition at line <a class="el" href="dbus-mempool_8c_source.html#l00138">138</a> of file <a class="el" href="dbus-mempool_8c_source.html">dbus-mempool.c</a>.</p>
<p>References <a class="el" href="dbus-mempool_8c_source.html#l00106">allocated_elements</a>, <a class="el" href="dbus-mempool_8c_source.html#l00101">block_size</a>, <a class="el" href="dbus-memory_8h_source.html#l00059">dbus_new0</a>, <a class="el" href="dbus-mempool_8c_source.html#l00100">element_size</a>, <a class="el" href="group__DBusMacros.html#gaa93f0eb578d23995850d61f7d61c55c1">FALSE</a>, <a class="el" href="group__DBusMacros.html#ga070d2ce7b6bb7e5c05602aa8c308d0c4">NULL</a>, and <a class="el" href="dbus-mempool_8c_source.html#l00102">zero_elements</a>.</p>
<p>Referenced by <a class="el" href="dbus-hash_8c_source.html#l00285">_dbus_hash_table_new()</a>.</p>
</div>
</div>
</div><!-- contents -->
<hr class="footer"/><address class="footer"><small>
Generated on Thu Mar 3 2016 17:50:33 for D-Bus by  <a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/>
</a> 1.7.6.1
</small></address>
</body>
</html>