<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1"> <title>memory pools</title> <link href="doxygen.css" rel="stylesheet" type="text/css"> </head><body> <!-- Generated by Doxygen 1.2.15 --> <center> <a class="qindex" href="index.html">Main Page</a> <a class="qindex" href="modules.html">Modules</a> <a class="qindex" href="annotated.html">Data Structures</a> <a class="qindex" href="files.html">File List</a> <a class="qindex" href="functions.html">Data Fields</a> <a class="qindex" href="pages.html">Related Pages</a> </center> <hr><h1>memory pools<br> <small> [<a class="el" href="group__DBusInternals.html">D-BUS internal implementation details</a>]</small> </h1>DBusMemPool object. <a href="#_details">More...</a><table border=0 cellpadding=0 cellspacing=0> <tr><td colspan=2><br><h2>Typedefs</h2></td></tr> <tr><td nowrap align=right valign=top>typedef DBusMemPool </td><td valign=bottom><a class="el" href="group__DBusMemPool.html#a4">DBusMemPool</a></td></tr> <tr><td> </td><td><font size=-1><em>Opaque object representing a memory pool.</em> <a href="#a4">More...</a><em></em></font><br><br></td></tr> <tr><td colspan=2><br><h2>Functions</h2></td></tr> <tr><td nowrap align=right valign=top>DBusMemPool * </td><td valign=bottom><a class="el" href="group__DBusMemPool.html#a0">_dbus_mem_pool_new</a> (int <a class="el" href="structDBusMemPool.html#m0">element_size</a>, <a class="el" href="group__DBusTypes.html#a2">dbus_bool_t</a> <a class="el" href="structDBusMemPool.html#m2">zero_elements</a>)</td></tr> <tr><td> </td><td><font size=-1><em>Creates a new memory pool, or returns <a class="el" href="group__DBusMacros.html#a4">NULL</a> on failure.</em> <a href="#a0">More...</a><em></em></font><br><br></td></tr> <tr><td nowrap align=right valign=top>void </td><td valign=bottom><a class="el" href="group__DBusMemPool.html#a1">_dbus_mem_pool_free</a> (DBusMemPool *pool)</td></tr> <tr><td> </td><td><font size=-1><em>Frees a memory pool (and all elements allocated from it).</em> <a href="#a1">More...</a><em></em></font><br><br></td></tr> <tr><td nowrap align=right valign=top>void * </td><td valign=bottom><a class="el" href="group__DBusMemPool.html#a2">_dbus_mem_pool_alloc</a> (DBusMemPool *pool)</td></tr> <tr><td> </td><td><font size=-1><em>Allocates an object from the memory pool.</em> <a href="#a2">More...</a><em></em></font><br><br></td></tr> <tr><td nowrap align=right valign=top><a class="el" href="group__DBusTypes.html#a2">dbus_bool_t</a> </td><td valign=bottom><a class="el" href="group__DBusMemPool.html#a3">_dbus_mem_pool_dealloc</a> (DBusMemPool *pool, void *element)</td></tr> <tr><td> </td><td><font size=-1><em>Deallocates an object previously created with <a class="el" href="group__DBusMemPool.html#a2">_dbus_mem_pool_alloc</a>().</em> <a href="#a3">More...</a><em></em></font><br><br></td></tr> </table> <hr><a name="_details"></a><h2>Detailed Description</h2> DBusMemPool object. <p> <p> Types and functions related to DBusMemPool. 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. <hr><h2>Typedef Documentation</h2> <a name="a4" doxytag="dbus-mempool.h::DBusMemPool"></a><p> <table width="100%" cellpadding="2" cellspacing="0" border="0"> <tr> <td class="md"> <table cellpadding="0" cellspacing="0" border="0"> <tr> <td class="md" nowrap valign="top"> DBusMemPool </table> </td> </tr> </table> <table cellspacing=5 cellpadding=0 border=0> <tr> <td> </td> <td> <p> Opaque object representing a memory pool. <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> 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>. </td> </tr> </table> <hr><h2>Function Documentation</h2> <a name="a2" doxytag="dbus-mempool.c::_dbus_mem_pool_alloc"></a><p> <table width="100%" cellpadding="2" cellspacing="0" border="0"> <tr> <td class="md"> <table cellpadding="0" cellspacing="0" border="0"> <tr> <td class="md" nowrap valign="top"> void* _dbus_mem_pool_alloc </td> <td class="md" valign="top">( </td> <td class="md" nowrap valign="top"><a class="el" href="structDBusMemPool.html">DBusMemPool</a> * </td> <td class="mdname1" valign="top" nowrap> <em>pool</em> </td> <td class="md" valign="top">) </td> <td class="md" nowrap></td> </tr> </table> </td> </tr> </table> <table cellspacing=5 cellpadding=0 border=0> <tr> <td> </td> <td> <p> Allocates an object from the memory pool. <p> The object must be freed with <a class="el" href="group__DBusMemPool.html#a3">_dbus_mem_pool_dealloc</a>().<dl compact><dt><b> Parameters: </b><dd> <table border=0 cellspacing=2 cellpadding=0> <tr><td valign=top><em>pool</em> </td><td> the memory pool </td></tr> </table> </dl><dl compact><dt><b> Returns: </b><dd> the allocated object or <a class="el" href="group__DBusMacros.html#a4">NULL</a> if no memory. </dl> <p> Definition at line <a class="el" href="dbus-mempool_8c-source.html#l00208">208</a> of file <a class="el" href="dbus-mempool_8c-source.html">dbus-mempool.c</a>. <p> References <a class="el" href="dbus-mempool_8c-source.html#l00104">allocated_elements</a>, <a class="el" href="dbus-mempool_8c-source.html#l00099">block_size</a>, <a class="el" href="dbus-mempool_8c-source.html#l00103">blocks</a>, <a class="el" href="dbus-mempool_8c-source.html#l00098">element_size</a>, <a class="el" href="dbus-mempool_8c-source.html#l00090">DBusMemBlock::elements</a>, <a class="el" href="dbus-mempool_8c-source.html#l00102">free_elements</a>, <a class="el" href="dbus-mempool_8c-source.html#l00082">DBusMemBlock::next</a>, <a class="el" href="dbus-mempool_8c-source.html#l00061">DBusFreedElement::next</a>, <a class="el" href="dbus-mempool_8c-source.html#l00088">DBusMemBlock::used_so_far</a>, and <a class="el" href="dbus-mempool_8c-source.html#l00100">zero_elements</a>. </td> </tr> </table> <a name="a3" doxytag="dbus-mempool.c::_dbus_mem_pool_dealloc"></a><p> <table width="100%" cellpadding="2" cellspacing="0" border="0"> <tr> <td class="md"> <table cellpadding="0" cellspacing="0" border="0"> <tr> <td class="md" nowrap valign="top"> <a class="el" href="group__DBusTypes.html#a2">dbus_bool_t</a> _dbus_mem_pool_dealloc </td> <td class="md" valign="top">( </td> <td class="md" nowrap valign="top"><a class="el" href="structDBusMemPool.html">DBusMemPool</a> * </td> <td class="mdname" nowrap> <em>pool</em>, </td> </tr> <tr> <td></td> <td></td> <td class="md" nowrap>void * </td> <td class="mdname" nowrap> <em>element</em></td> </tr> <tr> <td></td> <td class="md">) </td> <td class="md" colspan="2"></td> </tr> </table> </td> </tr> </table> <table cellspacing=5 cellpadding=0 border=0> <tr> <td> </td> <td> <p> Deallocates an object previously created with <a class="el" href="group__DBusMemPool.html#a2">_dbus_mem_pool_alloc</a>(). <p> The previous object must have come from this same pool. <dl compact><dt><b> Parameters: </b><dd> <table border=0 cellspacing=2 cellpadding=0> <tr><td valign=top><em>pool</em> </td><td> the memory pool </td></tr> <tr><td valign=top><em>element</em> </td><td> the element earlier allocated. </td></tr> </table> </dl><dl compact><dt><b> Returns: </b><dd> <a class="el" href="group__DBusMacros.html#a2">TRUE</a> if there are no remaining allocated elements </dl> <p> Definition at line <a class="el" href="dbus-mempool_8c-source.html#l00336">336</a> of file <a class="el" href="dbus-mempool_8c-source.html">dbus-mempool.c</a>. <p> References <a class="el" href="dbus-mempool_8c-source.html#l00104">allocated_elements</a>, <a class="el" href="dbus-mempool_8c-source.html#l00103">blocks</a>, <a class="el" href="dbus-mempool_8c-source.html#l00090">DBusMemBlock::elements</a>, <a class="el" href="dbus-mempool_8c-source.html#l00102">free_elements</a>, <a class="el" href="dbus-mempool_8c-source.html#l00082">DBusMemBlock::next</a>, and <a class="el" href="dbus-mempool_8c-source.html#l00061">DBusFreedElement::next</a>. </td> </tr> </table> <a name="a1" doxytag="dbus-mempool.c::_dbus_mem_pool_free"></a><p> <table width="100%" cellpadding="2" cellspacing="0" border="0"> <tr> <td class="md"> <table cellpadding="0" cellspacing="0" border="0"> <tr> <td class="md" nowrap valign="top"> void _dbus_mem_pool_free </td> <td class="md" valign="top">( </td> <td class="md" nowrap valign="top"><a class="el" href="structDBusMemPool.html">DBusMemPool</a> * </td> <td class="mdname1" valign="top" nowrap> <em>pool</em> </td> <td class="md" valign="top">) </td> <td class="md" nowrap></td> </tr> </table> </td> </tr> </table> <table cellspacing=5 cellpadding=0 border=0> <tr> <td> </td> <td> <p> Frees a memory pool (and all elements allocated from it). <p> <dl compact><dt><b> Parameters: </b><dd> <table border=0 cellspacing=2 cellpadding=0> <tr><td valign=top><em>pool</em> </td><td> the memory pool. </td></tr> </table> </dl> <p> Definition at line <a class="el" href="dbus-mempool_8c-source.html#l00183">183</a> of file <a class="el" href="dbus-mempool_8c-source.html">dbus-mempool.c</a>. <p> References <a class="el" href="dbus-mempool_8c-source.html#l00103">blocks</a>, and <a class="el" href="dbus-mempool_8c-source.html#l00082">DBusMemBlock::next</a>. </td> </tr> </table> <a name="a0" doxytag="dbus-mempool.c::_dbus_mem_pool_new"></a><p> <table width="100%" cellpadding="2" cellspacing="0" border="0"> <tr> <td class="md"> <table cellpadding="0" cellspacing="0" border="0"> <tr> <td class="md" nowrap valign="top"> <a class="el" href="structDBusMemPool.html">DBusMemPool</a>* _dbus_mem_pool_new </td> <td class="md" valign="top">( </td> <td class="md" nowrap valign="top">int </td> <td class="mdname" nowrap> <em>element_size</em>, </td> </tr> <tr> <td></td> <td></td> <td class="md" nowrap><a class="el" href="group__DBusTypes.html#a2">dbus_bool_t</a> </td> <td class="mdname" nowrap> <em>zero_elements</em></td> </tr> <tr> <td></td> <td class="md">) </td> <td class="md" colspan="2"></td> </tr> </table> </td> </tr> </table> <table cellspacing=5 cellpadding=0 border=0> <tr> <td> </td> <td> <p> Creates a new memory pool, or returns <a class="el" href="group__DBusMacros.html#a4">NULL</a> on failure. <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.<dl compact><dt><b> Parameters: </b><dd> <table border=0 cellspacing=2 cellpadding=0> <tr><td valign=top><em>element_size</em> </td><td> size of an element allocated from the pool. </td></tr> <tr><td valign=top><em>zero_elements</em> </td><td> whether to zero-initialize elements </td></tr> </table> </dl><dl compact><dt><b> Returns: </b><dd> the new pool or <a class="el" href="group__DBusMacros.html#a4">NULL</a> </dl> <p> Definition at line <a class="el" href="dbus-mempool_8c-source.html#l00136">136</a> of file <a class="el" href="dbus-mempool_8c-source.html">dbus-mempool.c</a>. <p> References <a class="el" href="dbus-mempool_8c-source.html#l00104">allocated_elements</a>, <a class="el" href="dbus-mempool_8c-source.html#l00099">block_size</a>, <a class="el" href="dbus-mempool_8c-source.html#l00098">element_size</a>, and <a class="el" href="dbus-mempool_8c-source.html#l00100">zero_elements</a>. </td> </tr> </table> <hr><address align="right"><small>Generated on Wed Jun 9 05:01:28 2004 for D-BUS by <a href="http://www.doxygen.org/index.html"> <img src="doxygen.png" alt="doxygen" align="middle" border=0 width=110 height=53></a>1.2.15 </small></address> </body> </html>