<!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"/> <title>Apache Portable Runtime: Pool Debugging functions.</title> <link href="tabs.css" rel="stylesheet" type="text/css"/> <link href="search/search.css" rel="stylesheet" type="text/css"/> <script type="text/javascript" src="search/search.js"></script> <link href="doxygen.css" rel="stylesheet" type="text/css"/> </head> <body onload='searchBox.OnSelectItem(0);'> <!-- Generated by Doxygen 1.7.3 --> <script type="text/javascript"><!-- var searchBox = new SearchBox("searchBox", "search",false,'Search'); --></script> <div id="top"> <div id="titlearea"> <table cellspacing="0" cellpadding="0"> <tbody> <tr style="height: 56px;"> <td style="padding-left: 0.5em;"> <div id="projectname">Apache Portable Runtime</div> </td> </tr> </tbody> </table> </div> <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="namespaces.html"><span>Namespaces</span></a></li> <li><a href="annotated.html"><span>Data Structures</span></a></li> <li><a href="files.html"><span>Files</span></a></li> <li id="searchli"> <div id="MSearchBox" class="MSearchBoxInactive"> <span class="left"> <img id="MSearchSelect" src="search/mag_sel.png" onmouseover="return searchBox.OnSearchSelectShow()" onmouseout="return searchBox.OnSearchSelectHide()" alt=""/> <input type="text" id="MSearchField" value="Search" accesskey="S" onfocus="searchBox.OnSearchFieldFocus(true)" onblur="searchBox.OnSearchFieldFocus(false)" onkeyup="searchBox.OnSearchFieldChange(event)"/> </span><span class="right"> <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a> </span> </div> </li> </ul> </div> </div> <div class="header"> <div class="summary"> <a href="#func-members">Functions</a> </div> <div class="headertitle"> <h1>Pool Debugging functions.</h1> </div> <div class="ingroups"><a class="el" href="group__apr__pools.html">Memory Pool Functions</a></div></div> <div class="contents"> <table class="memberdecls"> <tr><td colspan="2"><h2><a name="func-members"></a> Functions</h2></td></tr> <tr><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="group___pool_debug.html#gaecd956092f81c70117507ad8cbca8ea7">apr_pool_join</a> (<a class="el" href="group__apr__pools.html#gaf137f28edcf9a086cd6bc36c20d7cdfb">apr_pool_t</a> *p, <a class="el" href="group__apr__pools.html#gaf137f28edcf9a086cd6bc36c20d7cdfb">apr_pool_t</a> *sub)</td></tr> <tr><td class="memItemLeft" align="right" valign="top"><a class="el" href="group__apr__pools.html#gaf137f28edcf9a086cd6bc36c20d7cdfb">apr_pool_t</a> * </td><td class="memItemRight" valign="bottom"><a class="el" href="group___pool_debug.html#ga0bc40d9069709020e3643492dae2ccb0">apr_pool_find</a> (const void *mem)</td></tr> <tr><td class="memItemLeft" align="right" valign="top">apr_size_t </td><td class="memItemRight" valign="bottom"><a class="el" href="group___pool_debug.html#ga22462da23d70dfde389a370b131cd351">apr_pool_num_bytes</a> (<a class="el" href="group__apr__pools.html#gaf137f28edcf9a086cd6bc36c20d7cdfb">apr_pool_t</a> *p, int recurse)</td></tr> <tr><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="group___pool_debug.html#ga24f8f0287478fa71f77d0ce4ec035e4a">apr_pool_lock</a> (<a class="el" href="group__apr__pools.html#gaf137f28edcf9a086cd6bc36c20d7cdfb">apr_pool_t</a> *pool, int flag)</td></tr> </table> <hr/><a name="_details"></a><h2>Detailed Description</h2> <p>pools have nested lifetimes -- sub_pools are destroyed when the parent pool is cleared. We allow certain liberties with operations on things such as tables (and on other structures in a more general sense) where we allow the caller to insert values into a table which were not allocated from the table's pool. The table's data will remain valid as long as all the pools from which its values are allocated remain valid.</p> <p>For example, if B is a sub pool of A, and you build a table T in pool B, then it's safe to insert data allocated in A or B into T (because B lives at most as long as A does, and T is destroyed when B is cleared/destroyed). On the other hand, if S is a table in pool A, it is safe to insert data allocated in A into S, but it is *not safe* to insert data allocated from B into S... because B can be cleared/destroyed before A is (which would leave dangling pointers in T's data structures).</p> <p>In general we say that it is safe to insert data into a table T if the data is allocated in any ancestor of T's pool. This is the basis on which the APR_POOL_DEBUG code works -- it tests these ancestor relationships for all data inserted into tables. APR_POOL_DEBUG also provides tools (apr_pool_find, and apr_pool_is_ancestor) for other folks to implement similar restrictions for their own data structures.</p> <p>However, sometimes this ancestor requirement is inconvenient -- sometimes it's necessary to create a sub pool where the sub pool is guaranteed to have the same lifetime as the parent pool. This is a guarantee implemented by the *caller*, not by the pool code. That is, the caller guarantees they won't destroy the sub pool individually prior to destroying the parent pool.</p> <p>In this case the caller must call <a class="el" href="group___pool_debug.html#gaecd956092f81c70117507ad8cbca8ea7">apr_pool_join()</a> to indicate this guarantee to the APR_POOL_DEBUG code.</p> <p>These functions are only implemented when <a class="el" href="group__apr__pools.html#gad898431056ee6f544e0632f2cf5706c4">APR_POOL_DEBUG</a> is set. </p> <hr/><h2>Function Documentation</h2> <a class="anchor" id="ga0bc40d9069709020e3643492dae2ccb0"></a><!-- doxytag: member="apr_pools.h::apr_pool_find" ref="ga0bc40d9069709020e3643492dae2ccb0" args="(const void *mem)" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname"><a class="el" href="group__apr__pools.html#gaf137f28edcf9a086cd6bc36c20d7cdfb">apr_pool_t</a>* apr_pool_find </td> <td>(</td> <td class="paramtype">const void * </td> <td class="paramname"><em>mem</em></td><td>)</td> <td></td> </tr> </table> </div> <div class="memdoc"> <p>Find a pool from something allocated in it. </p> <dl><dt><b>Parameters:</b></dt><dd> <table class="params"> <tr><td class="paramname">mem</td><td>The thing allocated in the pool </td></tr> </table> </dd> </dl> <dl class="return"><dt><b>Returns:</b></dt><dd>The pool it is allocated in </dd></dl> </div> </div> <a class="anchor" id="gaecd956092f81c70117507ad8cbca8ea7"></a><!-- doxytag: member="apr_pools.h::apr_pool_join" ref="gaecd956092f81c70117507ad8cbca8ea7" args="(apr_pool_t *p, apr_pool_t *sub)" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">void apr_pool_join </td> <td>(</td> <td class="paramtype"><a class="el" href="group__apr__pools.html#gaf137f28edcf9a086cd6bc36c20d7cdfb">apr_pool_t</a> * </td> <td class="paramname"><em>p</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype"><a class="el" href="group__apr__pools.html#gaf137f28edcf9a086cd6bc36c20d7cdfb">apr_pool_t</a> * </td> <td class="paramname"><em>sub</em> </td> </tr> <tr> <td></td> <td>)</td> <td></td><td></td> </tr> </table> </div> <div class="memdoc"> <p>Guarantee that a subpool has the same lifetime as the parent. </p> <dl><dt><b>Parameters:</b></dt><dd> <table class="params"> <tr><td class="paramname">p</td><td>The parent pool </td></tr> <tr><td class="paramname">sub</td><td>The subpool </td></tr> </table> </dd> </dl> </div> </div> <a class="anchor" id="ga24f8f0287478fa71f77d0ce4ec035e4a"></a><!-- doxytag: member="apr_pools.h::apr_pool_lock" ref="ga24f8f0287478fa71f77d0ce4ec035e4a" args="(apr_pool_t *pool, int flag)" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">void apr_pool_lock </td> <td>(</td> <td class="paramtype"><a class="el" href="group__apr__pools.html#gaf137f28edcf9a086cd6bc36c20d7cdfb">apr_pool_t</a> * </td> <td class="paramname"><em>pool</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype">int </td> <td class="paramname"><em>flag</em> </td> </tr> <tr> <td></td> <td>)</td> <td></td><td></td> </tr> </table> </div> <div class="memdoc"> <p>Lock a pool </p> <dl><dt><b>Parameters:</b></dt><dd> <table class="params"> <tr><td class="paramname">pool</td><td>The pool to lock </td></tr> <tr><td class="paramname">flag</td><td>The flag </td></tr> </table> </dd> </dl> </div> </div> <a class="anchor" id="ga22462da23d70dfde389a370b131cd351"></a><!-- doxytag: member="apr_pools.h::apr_pool_num_bytes" ref="ga22462da23d70dfde389a370b131cd351" args="(apr_pool_t *p, int recurse)" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">apr_size_t apr_pool_num_bytes </td> <td>(</td> <td class="paramtype"><a class="el" href="group__apr__pools.html#gaf137f28edcf9a086cd6bc36c20d7cdfb">apr_pool_t</a> * </td> <td class="paramname"><em>p</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype">int </td> <td class="paramname"><em>recurse</em> </td> </tr> <tr> <td></td> <td>)</td> <td></td><td></td> </tr> </table> </div> <div class="memdoc"> <p>Report the number of bytes currently in the pool </p> <dl><dt><b>Parameters:</b></dt><dd> <table class="params"> <tr><td class="paramname">p</td><td>The pool to inspect </td></tr> <tr><td class="paramname">recurse</td><td>Recurse/include the subpools' sizes </td></tr> </table> </dd> </dl> <dl class="return"><dt><b>Returns:</b></dt><dd>The number of bytes </dd></dl> </div> </div> </div> <!--- window showing the filter options --> <div id="MSearchSelectWindow" onmouseover="return searchBox.OnSearchSelectShow()" onmouseout="return searchBox.OnSearchSelectHide()" onkeydown="return searchBox.OnSearchSelectKey(event)"> <a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(0)"><span class="SelectionMark"> </span>All</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(1)"><span class="SelectionMark"> </span>Data Structures</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(2)"><span class="SelectionMark"> </span>Namespaces</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(3)"><span class="SelectionMark"> </span>Files</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(4)"><span class="SelectionMark"> </span>Functions</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(5)"><span class="SelectionMark"> </span>Variables</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(6)"><span class="SelectionMark"> </span>Typedefs</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(7)"><span class="SelectionMark"> </span>Enumerations</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(8)"><span class="SelectionMark"> </span>Enumerator</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(9)"><span class="SelectionMark"> </span>Defines</a></div> <!-- iframe showing the search results (closed by default) --> <div id="MSearchResultsWindow"> <iframe src="" frameborder="0" name="MSearchResults" id="MSearchResults"> </iframe> </div> <hr class="footer"/><address class="footer"><small>Generated on Wed May 25 2011 for Apache Portable Runtime by  <a href="http://www.doxygen.org/index.html"> <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.7.3 </small></address> </body> </html>