docs/api-2.1/mempool_8h.html

changeset 390
d345541018fa
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/docs/api-2.1/mempool_8h.html	Sat Feb 06 19:11:44 2021 +0100
     1.3 @@ -0,0 +1,517 @@
     1.4 +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
     1.5 +<html xmlns="http://www.w3.org/1999/xhtml">
     1.6 +<head>
     1.7 +<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
     1.8 +<meta http-equiv="X-UA-Compatible" content="IE=9"/>
     1.9 +<meta name="generator" content="Doxygen 1.8.13"/>
    1.10 +<meta name="viewport" content="width=device-width, initial-scale=1"/>
    1.11 +<title>ucx: /home/mike/workspace/c/ucx/src/ucx/mempool.h File Reference</title>
    1.12 +<link href="tabs.css" rel="stylesheet" type="text/css"/>
    1.13 +<script type="text/javascript" src="jquery.js"></script>
    1.14 +<script type="text/javascript" src="dynsections.js"></script>
    1.15 +<link href="search/search.css" rel="stylesheet" type="text/css"/>
    1.16 +<script type="text/javascript" src="search/searchdata.js"></script>
    1.17 +<script type="text/javascript" src="search/search.js"></script>
    1.18 +<link href="doxygen.css" rel="stylesheet" type="text/css" />
    1.19 +</head>
    1.20 +<body>
    1.21 +<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
    1.22 +<div id="titlearea">
    1.23 +<table cellspacing="0" cellpadding="0">
    1.24 + <tbody>
    1.25 + <tr style="height: 56px;">
    1.26 +  <td id="projectlogo"><img alt="Logo" src="uaplogo.png"/></td>
    1.27 +  <td id="projectalign" style="padding-left: 0.5em;">
    1.28 +   <div id="projectname">ucx
    1.29 +   </div>
    1.30 +   <div id="projectbrief">UAP Common Extensions</div>
    1.31 +  </td>
    1.32 + </tr>
    1.33 + </tbody>
    1.34 +</table>
    1.35 +</div>
    1.36 +<!-- end header part -->
    1.37 +<!-- Generated by Doxygen 1.8.13 -->
    1.38 +<script type="text/javascript">
    1.39 +var searchBox = new SearchBox("searchBox", "search",false,'Search');
    1.40 +</script>
    1.41 +<script type="text/javascript" src="menudata.js"></script>
    1.42 +<script type="text/javascript" src="menu.js"></script>
    1.43 +<script type="text/javascript">
    1.44 +$(function() {
    1.45 +  initMenu('',true,false,'search.php','Search');
    1.46 +  $(document).ready(function() { init_search(); });
    1.47 +});
    1.48 +</script>
    1.49 +<div id="main-nav"></div>
    1.50 +<!-- window showing the filter options -->
    1.51 +<div id="MSearchSelectWindow"
    1.52 +     onmouseover="return searchBox.OnSearchSelectShow()"
    1.53 +     onmouseout="return searchBox.OnSearchSelectHide()"
    1.54 +     onkeydown="return searchBox.OnSearchSelectKey(event)">
    1.55 +</div>
    1.56 +
    1.57 +<!-- iframe showing the search results (closed by default) -->
    1.58 +<div id="MSearchResultsWindow">
    1.59 +<iframe src="javascript:void(0)" frameborder="0" 
    1.60 +        name="MSearchResults" id="MSearchResults">
    1.61 +</iframe>
    1.62 +</div>
    1.63 +
    1.64 +<div id="nav-path" class="navpath">
    1.65 +  <ul>
    1.66 +<li class="navelem"><a class="el" href="dir_68267d1309a1af8e8297ef4c3efbcdba.html">src</a></li><li class="navelem"><a class="el" href="dir_69f4ea29401808fe6229564976cde3ce.html">ucx</a></li>  </ul>
    1.67 +</div>
    1.68 +</div><!-- top -->
    1.69 +<div class="header">
    1.70 +  <div class="summary">
    1.71 +<a href="#nested-classes">Data Structures</a> &#124;
    1.72 +<a href="#define-members">Macros</a> &#124;
    1.73 +<a href="#func-members">Functions</a>  </div>
    1.74 +  <div class="headertitle">
    1.75 +<div class="title">mempool.h File Reference</div>  </div>
    1.76 +</div><!--header-->
    1.77 +<div class="contents">
    1.78 +
    1.79 +<p>Memory pool implementation.  
    1.80 +<a href="#details">More...</a></p>
    1.81 +<div class="textblock"><code>#include &quot;<a class="el" href="ucx_8h_source.html">ucx.h</a>&quot;</code><br />
    1.82 +<code>#include &quot;<a class="el" href="allocator_8h_source.html">allocator.h</a>&quot;</code><br />
    1.83 +<code>#include &lt;stddef.h&gt;</code><br />
    1.84 +</div>
    1.85 +<p><a href="mempool_8h_source.html">Go to the source code of this file.</a></p>
    1.86 +<table class="memberdecls">
    1.87 +<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="nested-classes"></a>
    1.88 +Data Structures</h2></td></tr>
    1.89 +<tr class="memitem:"><td class="memItemLeft" align="right" valign="top">struct &#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="structUcxMempool.html">UcxMempool</a></td></tr>
    1.90 +<tr class="memdesc:"><td class="mdescLeft">&#160;</td><td class="mdescRight">UCX mempool structure.  <a href="structUcxMempool.html#details">More...</a><br /></td></tr>
    1.91 +<tr class="separator:"><td class="memSeparator" colspan="2">&#160;</td></tr>
    1.92 +</table><table class="memberdecls">
    1.93 +<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="define-members"></a>
    1.94 +Macros</h2></td></tr>
    1.95 +<tr class="memitem:a49f7bd1da5ac201d0cf54dc0f0d82dd2"><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="mempool_8h.html#a49f7bd1da5ac201d0cf54dc0f0d82dd2">ucx_mempool_new_default</a>()&#160;&#160;&#160;<a class="el" href="mempool_8h.html#ad71cb8c3b6fdb30360376a8b372ef22a">ucx_mempool_new</a>(16)</td></tr>
    1.96 +<tr class="memdesc:a49f7bd1da5ac201d0cf54dc0f0d82dd2"><td class="mdescLeft">&#160;</td><td class="mdescRight">Shorthand for a new default memory pool with a capacity of 16 elements.  <a href="#a49f7bd1da5ac201d0cf54dc0f0d82dd2">More...</a><br /></td></tr>
    1.97 +<tr class="separator:a49f7bd1da5ac201d0cf54dc0f0d82dd2"><td class="memSeparator" colspan="2">&#160;</td></tr>
    1.98 +</table><table class="memberdecls">
    1.99 +<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="func-members"></a>
   1.100 +Functions</h2></td></tr>
   1.101 +<tr class="memitem:ad71cb8c3b6fdb30360376a8b372ef22a"><td class="memItemLeft" align="right" valign="top"><a class="el" href="structUcxMempool.html">UcxMempool</a> *&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="mempool_8h.html#ad71cb8c3b6fdb30360376a8b372ef22a">ucx_mempool_new</a> (size_t n)</td></tr>
   1.102 +<tr class="memdesc:ad71cb8c3b6fdb30360376a8b372ef22a"><td class="mdescLeft">&#160;</td><td class="mdescRight">Creates a memory pool with the specified initial size.  <a href="#ad71cb8c3b6fdb30360376a8b372ef22a">More...</a><br /></td></tr>
   1.103 +<tr class="separator:ad71cb8c3b6fdb30360376a8b372ef22a"><td class="memSeparator" colspan="2">&#160;</td></tr>
   1.104 +<tr class="memitem:aaf75b5016098723a9280531ccc3a6d77"><td class="memItemLeft" align="right" valign="top">int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="mempool_8h.html#aaf75b5016098723a9280531ccc3a6d77">ucx_mempool_chcap</a> (<a class="el" href="structUcxMempool.html">UcxMempool</a> *pool, size_t newcap)</td></tr>
   1.105 +<tr class="memdesc:aaf75b5016098723a9280531ccc3a6d77"><td class="mdescLeft">&#160;</td><td class="mdescRight">Resizes a memory pool.  <a href="#aaf75b5016098723a9280531ccc3a6d77">More...</a><br /></td></tr>
   1.106 +<tr class="separator:aaf75b5016098723a9280531ccc3a6d77"><td class="memSeparator" colspan="2">&#160;</td></tr>
   1.107 +<tr class="memitem:a2ae492b8f2878ccc9837ac213dced11e"><td class="memItemLeft" align="right" valign="top">void *&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="mempool_8h.html#a2ae492b8f2878ccc9837ac213dced11e">ucx_mempool_malloc</a> (<a class="el" href="structUcxMempool.html">UcxMempool</a> *pool, size_t n)</td></tr>
   1.108 +<tr class="memdesc:a2ae492b8f2878ccc9837ac213dced11e"><td class="mdescLeft">&#160;</td><td class="mdescRight">Allocates pooled memory.  <a href="#a2ae492b8f2878ccc9837ac213dced11e">More...</a><br /></td></tr>
   1.109 +<tr class="separator:a2ae492b8f2878ccc9837ac213dced11e"><td class="memSeparator" colspan="2">&#160;</td></tr>
   1.110 +<tr class="memitem:a4b9142011824ae24f00fabe128417d69"><td class="memItemLeft" align="right" valign="top">void *&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="mempool_8h.html#a4b9142011824ae24f00fabe128417d69">ucx_mempool_calloc</a> (<a class="el" href="structUcxMempool.html">UcxMempool</a> *pool, size_t nelem, size_t elsize)</td></tr>
   1.111 +<tr class="memdesc:a4b9142011824ae24f00fabe128417d69"><td class="mdescLeft">&#160;</td><td class="mdescRight">Allocates a pooled memory array.  <a href="#a4b9142011824ae24f00fabe128417d69">More...</a><br /></td></tr>
   1.112 +<tr class="separator:a4b9142011824ae24f00fabe128417d69"><td class="memSeparator" colspan="2">&#160;</td></tr>
   1.113 +<tr class="memitem:a660ef42520ed6737c2e77aae18e3a7a4"><td class="memItemLeft" align="right" valign="top">void *&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="mempool_8h.html#a660ef42520ed6737c2e77aae18e3a7a4">ucx_mempool_realloc</a> (<a class="el" href="structUcxMempool.html">UcxMempool</a> *pool, void *ptr, size_t n)</td></tr>
   1.114 +<tr class="memdesc:a660ef42520ed6737c2e77aae18e3a7a4"><td class="mdescLeft">&#160;</td><td class="mdescRight">Reallocates pooled memory.  <a href="#a660ef42520ed6737c2e77aae18e3a7a4">More...</a><br /></td></tr>
   1.115 +<tr class="separator:a660ef42520ed6737c2e77aae18e3a7a4"><td class="memSeparator" colspan="2">&#160;</td></tr>
   1.116 +<tr class="memitem:aefa26e3015f5aefadbfc74221bd246ac"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="mempool_8h.html#aefa26e3015f5aefadbfc74221bd246ac">ucx_mempool_free</a> (<a class="el" href="structUcxMempool.html">UcxMempool</a> *pool, void *ptr)</td></tr>
   1.117 +<tr class="memdesc:aefa26e3015f5aefadbfc74221bd246ac"><td class="mdescLeft">&#160;</td><td class="mdescRight">Frees pooled memory.  <a href="#aefa26e3015f5aefadbfc74221bd246ac">More...</a><br /></td></tr>
   1.118 +<tr class="separator:aefa26e3015f5aefadbfc74221bd246ac"><td class="memSeparator" colspan="2">&#160;</td></tr>
   1.119 +<tr class="memitem:af096378da7e9bfbed3088497cf4c15bf"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="mempool_8h.html#af096378da7e9bfbed3088497cf4c15bf">ucx_mempool_destroy</a> (<a class="el" href="structUcxMempool.html">UcxMempool</a> *pool)</td></tr>
   1.120 +<tr class="memdesc:af096378da7e9bfbed3088497cf4c15bf"><td class="mdescLeft">&#160;</td><td class="mdescRight">Destroys a memory pool.  <a href="#af096378da7e9bfbed3088497cf4c15bf">More...</a><br /></td></tr>
   1.121 +<tr class="separator:af096378da7e9bfbed3088497cf4c15bf"><td class="memSeparator" colspan="2">&#160;</td></tr>
   1.122 +<tr class="memitem:adb788e7ec24cd7dbdea6381539c549f2"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="mempool_8h.html#adb788e7ec24cd7dbdea6381539c549f2">ucx_mempool_set_destr</a> (void *ptr, <a class="el" href="ucx_8h.html#ad2b370c2809914c8b7fedab163c266b3">ucx_destructor</a> func)</td></tr>
   1.123 +<tr class="memdesc:adb788e7ec24cd7dbdea6381539c549f2"><td class="mdescLeft">&#160;</td><td class="mdescRight">Sets a destructor function for the specified memory.  <a href="#adb788e7ec24cd7dbdea6381539c549f2">More...</a><br /></td></tr>
   1.124 +<tr class="separator:adb788e7ec24cd7dbdea6381539c549f2"><td class="memSeparator" colspan="2">&#160;</td></tr>
   1.125 +<tr class="memitem:af47b6b7c40f8f263dc28cc9a4e77b27c"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="mempool_8h.html#af47b6b7c40f8f263dc28cc9a4e77b27c">ucx_mempool_reg_destr</a> (<a class="el" href="structUcxMempool.html">UcxMempool</a> *pool, void *ptr, <a class="el" href="ucx_8h.html#ad2b370c2809914c8b7fedab163c266b3">ucx_destructor</a> destr)</td></tr>
   1.126 +<tr class="memdesc:af47b6b7c40f8f263dc28cc9a4e77b27c"><td class="mdescLeft">&#160;</td><td class="mdescRight">Registers a destructor function for the specified (non-pooled) memory.  <a href="#af47b6b7c40f8f263dc28cc9a4e77b27c">More...</a><br /></td></tr>
   1.127 +<tr class="separator:af47b6b7c40f8f263dc28cc9a4e77b27c"><td class="memSeparator" colspan="2">&#160;</td></tr>
   1.128 +</table>
   1.129 +<a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2>
   1.130 +<div class="textblock"><p>Memory pool implementation. </p>
   1.131 +<dl class="section author"><dt>Author</dt><dd>Mike Becker </dd>
   1.132 +<dd>
   1.133 +Olaf Wintermann </dd></dl>
   1.134 +</div><h2 class="groupheader">Macro Definition Documentation</h2>
   1.135 +<a id="a49f7bd1da5ac201d0cf54dc0f0d82dd2"></a>
   1.136 +<h2 class="memtitle"><span class="permalink"><a href="#a49f7bd1da5ac201d0cf54dc0f0d82dd2">&#9670;&nbsp;</a></span>ucx_mempool_new_default</h2>
   1.137 +
   1.138 +<div class="memitem">
   1.139 +<div class="memproto">
   1.140 +      <table class="memname">
   1.141 +        <tr>
   1.142 +          <td class="memname">#define ucx_mempool_new_default</td>
   1.143 +          <td>(</td>
   1.144 +          <td class="paramname"></td><td>)</td>
   1.145 +          <td>&#160;&#160;&#160;<a class="el" href="mempool_8h.html#ad71cb8c3b6fdb30360376a8b372ef22a">ucx_mempool_new</a>(16)</td>
   1.146 +        </tr>
   1.147 +      </table>
   1.148 +</div><div class="memdoc">
   1.149 +
   1.150 +<p>Shorthand for a new default memory pool with a capacity of 16 elements. </p>
   1.151 +
   1.152 +</div>
   1.153 +</div>
   1.154 +<h2 class="groupheader">Function Documentation</h2>
   1.155 +<a id="a4b9142011824ae24f00fabe128417d69"></a>
   1.156 +<h2 class="memtitle"><span class="permalink"><a href="#a4b9142011824ae24f00fabe128417d69">&#9670;&nbsp;</a></span>ucx_mempool_calloc()</h2>
   1.157 +
   1.158 +<div class="memitem">
   1.159 +<div class="memproto">
   1.160 +      <table class="memname">
   1.161 +        <tr>
   1.162 +          <td class="memname">void* ucx_mempool_calloc </td>
   1.163 +          <td>(</td>
   1.164 +          <td class="paramtype"><a class="el" href="structUcxMempool.html">UcxMempool</a> *&#160;</td>
   1.165 +          <td class="paramname"><em>pool</em>, </td>
   1.166 +        </tr>
   1.167 +        <tr>
   1.168 +          <td class="paramkey"></td>
   1.169 +          <td></td>
   1.170 +          <td class="paramtype">size_t&#160;</td>
   1.171 +          <td class="paramname"><em>nelem</em>, </td>
   1.172 +        </tr>
   1.173 +        <tr>
   1.174 +          <td class="paramkey"></td>
   1.175 +          <td></td>
   1.176 +          <td class="paramtype">size_t&#160;</td>
   1.177 +          <td class="paramname"><em>elsize</em>&#160;</td>
   1.178 +        </tr>
   1.179 +        <tr>
   1.180 +          <td></td>
   1.181 +          <td>)</td>
   1.182 +          <td></td><td></td>
   1.183 +        </tr>
   1.184 +      </table>
   1.185 +</div><div class="memdoc">
   1.186 +
   1.187 +<p>Allocates a pooled memory array. </p>
   1.188 +<p>The content of the allocated memory is set to zero.</p>
   1.189 +<dl class="params"><dt>Parameters</dt><dd>
   1.190 +  <table class="params">
   1.191 +    <tr><td class="paramname">pool</td><td>the memory pool </td></tr>
   1.192 +    <tr><td class="paramname">nelem</td><td>amount of elements to allocate </td></tr>
   1.193 +    <tr><td class="paramname">elsize</td><td>amount of memory per element </td></tr>
   1.194 +  </table>
   1.195 +  </dd>
   1.196 +</dl>
   1.197 +<dl class="section return"><dt>Returns</dt><dd>a pointer to the allocated memory </dd></dl>
   1.198 +<dl class="section see"><dt>See also</dt><dd><a class="el" href="allocator_8h.html#a2c0aba4221c1ac6801f03ed799f15b12" title="A function pointer to the allocators calloc() function. ">ucx_allocator_calloc()</a> </dd></dl>
   1.199 +
   1.200 +</div>
   1.201 +</div>
   1.202 +<a id="aaf75b5016098723a9280531ccc3a6d77"></a>
   1.203 +<h2 class="memtitle"><span class="permalink"><a href="#aaf75b5016098723a9280531ccc3a6d77">&#9670;&nbsp;</a></span>ucx_mempool_chcap()</h2>
   1.204 +
   1.205 +<div class="memitem">
   1.206 +<div class="memproto">
   1.207 +      <table class="memname">
   1.208 +        <tr>
   1.209 +          <td class="memname">int ucx_mempool_chcap </td>
   1.210 +          <td>(</td>
   1.211 +          <td class="paramtype"><a class="el" href="structUcxMempool.html">UcxMempool</a> *&#160;</td>
   1.212 +          <td class="paramname"><em>pool</em>, </td>
   1.213 +        </tr>
   1.214 +        <tr>
   1.215 +          <td class="paramkey"></td>
   1.216 +          <td></td>
   1.217 +          <td class="paramtype">size_t&#160;</td>
   1.218 +          <td class="paramname"><em>newcap</em>&#160;</td>
   1.219 +        </tr>
   1.220 +        <tr>
   1.221 +          <td></td>
   1.222 +          <td>)</td>
   1.223 +          <td></td><td></td>
   1.224 +        </tr>
   1.225 +      </table>
   1.226 +</div><div class="memdoc">
   1.227 +
   1.228 +<p>Resizes a memory pool. </p>
   1.229 +<p>This function will fail if the new capacity is not sufficient for the present data.</p>
   1.230 +<dl class="params"><dt>Parameters</dt><dd>
   1.231 +  <table class="params">
   1.232 +    <tr><td class="paramname">pool</td><td>the pool to resize </td></tr>
   1.233 +    <tr><td class="paramname">newcap</td><td>the new capacity </td></tr>
   1.234 +  </table>
   1.235 +  </dd>
   1.236 +</dl>
   1.237 +<dl class="section return"><dt>Returns</dt><dd>zero on success or non-zero on failure </dd></dl>
   1.238 +
   1.239 +</div>
   1.240 +</div>
   1.241 +<a id="af096378da7e9bfbed3088497cf4c15bf"></a>
   1.242 +<h2 class="memtitle"><span class="permalink"><a href="#af096378da7e9bfbed3088497cf4c15bf">&#9670;&nbsp;</a></span>ucx_mempool_destroy()</h2>
   1.243 +
   1.244 +<div class="memitem">
   1.245 +<div class="memproto">
   1.246 +      <table class="memname">
   1.247 +        <tr>
   1.248 +          <td class="memname">void ucx_mempool_destroy </td>
   1.249 +          <td>(</td>
   1.250 +          <td class="paramtype"><a class="el" href="structUcxMempool.html">UcxMempool</a> *&#160;</td>
   1.251 +          <td class="paramname"><em>pool</em></td><td>)</td>
   1.252 +          <td></td>
   1.253 +        </tr>
   1.254 +      </table>
   1.255 +</div><div class="memdoc">
   1.256 +
   1.257 +<p>Destroys a memory pool. </p>
   1.258 +<p>For each element the destructor function (if any) is called and the element is freed.</p>
   1.259 +<p>Each of the registered destructor function that has no corresponding element within the pool (namely those registered by ucx_mempool_reg_destr) is called interleaving with the element destruction, but with guarantee to the order in which they were registered (FIFO order).</p>
   1.260 +<dl class="params"><dt>Parameters</dt><dd>
   1.261 +  <table class="params">
   1.262 +    <tr><td class="paramname">pool</td><td>the mempool to destroy </td></tr>
   1.263 +  </table>
   1.264 +  </dd>
   1.265 +</dl>
   1.266 +
   1.267 +</div>
   1.268 +</div>
   1.269 +<a id="aefa26e3015f5aefadbfc74221bd246ac"></a>
   1.270 +<h2 class="memtitle"><span class="permalink"><a href="#aefa26e3015f5aefadbfc74221bd246ac">&#9670;&nbsp;</a></span>ucx_mempool_free()</h2>
   1.271 +
   1.272 +<div class="memitem">
   1.273 +<div class="memproto">
   1.274 +      <table class="memname">
   1.275 +        <tr>
   1.276 +          <td class="memname">void ucx_mempool_free </td>
   1.277 +          <td>(</td>
   1.278 +          <td class="paramtype"><a class="el" href="structUcxMempool.html">UcxMempool</a> *&#160;</td>
   1.279 +          <td class="paramname"><em>pool</em>, </td>
   1.280 +        </tr>
   1.281 +        <tr>
   1.282 +          <td class="paramkey"></td>
   1.283 +          <td></td>
   1.284 +          <td class="paramtype">void *&#160;</td>
   1.285 +          <td class="paramname"><em>ptr</em>&#160;</td>
   1.286 +        </tr>
   1.287 +        <tr>
   1.288 +          <td></td>
   1.289 +          <td>)</td>
   1.290 +          <td></td><td></td>
   1.291 +        </tr>
   1.292 +      </table>
   1.293 +</div><div class="memdoc">
   1.294 +
   1.295 +<p>Frees pooled memory. </p>
   1.296 +<p>Before freeing the memory, the specified destructor function (if any) is called.</p>
   1.297 +<p>If you specify memory, that is not pooled by the specified memory pool, the program will terminate with a call to <code>abort()</code>.</p>
   1.298 +<dl class="params"><dt>Parameters</dt><dd>
   1.299 +  <table class="params">
   1.300 +    <tr><td class="paramname">pool</td><td>the memory pool </td></tr>
   1.301 +    <tr><td class="paramname">ptr</td><td>a pointer to the memory that shall be freed </td></tr>
   1.302 +  </table>
   1.303 +  </dd>
   1.304 +</dl>
   1.305 +<dl class="section see"><dt>See also</dt><dd><a class="el" href="mempool_8h.html#adb788e7ec24cd7dbdea6381539c549f2" title="Sets a destructor function for the specified memory. ">ucx_mempool_set_destr()</a> </dd></dl>
   1.306 +
   1.307 +</div>
   1.308 +</div>
   1.309 +<a id="a2ae492b8f2878ccc9837ac213dced11e"></a>
   1.310 +<h2 class="memtitle"><span class="permalink"><a href="#a2ae492b8f2878ccc9837ac213dced11e">&#9670;&nbsp;</a></span>ucx_mempool_malloc()</h2>
   1.311 +
   1.312 +<div class="memitem">
   1.313 +<div class="memproto">
   1.314 +      <table class="memname">
   1.315 +        <tr>
   1.316 +          <td class="memname">void* ucx_mempool_malloc </td>
   1.317 +          <td>(</td>
   1.318 +          <td class="paramtype"><a class="el" href="structUcxMempool.html">UcxMempool</a> *&#160;</td>
   1.319 +          <td class="paramname"><em>pool</em>, </td>
   1.320 +        </tr>
   1.321 +        <tr>
   1.322 +          <td class="paramkey"></td>
   1.323 +          <td></td>
   1.324 +          <td class="paramtype">size_t&#160;</td>
   1.325 +          <td class="paramname"><em>n</em>&#160;</td>
   1.326 +        </tr>
   1.327 +        <tr>
   1.328 +          <td></td>
   1.329 +          <td>)</td>
   1.330 +          <td></td><td></td>
   1.331 +        </tr>
   1.332 +      </table>
   1.333 +</div><div class="memdoc">
   1.334 +
   1.335 +<p>Allocates pooled memory. </p>
   1.336 +<dl class="params"><dt>Parameters</dt><dd>
   1.337 +  <table class="params">
   1.338 +    <tr><td class="paramname">pool</td><td>the memory pool </td></tr>
   1.339 +    <tr><td class="paramname">n</td><td>amount of memory to allocate </td></tr>
   1.340 +  </table>
   1.341 +  </dd>
   1.342 +</dl>
   1.343 +<dl class="section return"><dt>Returns</dt><dd>a pointer to the allocated memory </dd></dl>
   1.344 +<dl class="section see"><dt>See also</dt><dd><a class="el" href="allocator_8h.html#a29f0f6a23a70db3b60635cd6dc384473" title="A function pointer to the allocators malloc() function. ">ucx_allocator_malloc()</a> </dd></dl>
   1.345 +
   1.346 +</div>
   1.347 +</div>
   1.348 +<a id="ad71cb8c3b6fdb30360376a8b372ef22a"></a>
   1.349 +<h2 class="memtitle"><span class="permalink"><a href="#ad71cb8c3b6fdb30360376a8b372ef22a">&#9670;&nbsp;</a></span>ucx_mempool_new()</h2>
   1.350 +
   1.351 +<div class="memitem">
   1.352 +<div class="memproto">
   1.353 +      <table class="memname">
   1.354 +        <tr>
   1.355 +          <td class="memname"><a class="el" href="structUcxMempool.html">UcxMempool</a>* ucx_mempool_new </td>
   1.356 +          <td>(</td>
   1.357 +          <td class="paramtype">size_t&#160;</td>
   1.358 +          <td class="paramname"><em>n</em></td><td>)</td>
   1.359 +          <td></td>
   1.360 +        </tr>
   1.361 +      </table>
   1.362 +</div><div class="memdoc">
   1.363 +
   1.364 +<p>Creates a memory pool with the specified initial size. </p>
   1.365 +<p>As the created memory pool automatically grows in size by factor two when trying to allocate memory on a full pool, it is recommended that you use a power of two for the initial size.</p>
   1.366 +<dl class="params"><dt>Parameters</dt><dd>
   1.367 +  <table class="params">
   1.368 +    <tr><td class="paramname">n</td><td>initial pool size (should be a power of two, e.g. 16) </td></tr>
   1.369 +  </table>
   1.370 +  </dd>
   1.371 +</dl>
   1.372 +<dl class="section return"><dt>Returns</dt><dd>a pointer to the new memory pool </dd></dl>
   1.373 +<dl class="section see"><dt>See also</dt><dd><a class="el" href="mempool_8h.html#a49f7bd1da5ac201d0cf54dc0f0d82dd2" title="Shorthand for a new default memory pool with a capacity of 16 elements. ">ucx_mempool_new_default()</a> </dd></dl>
   1.374 +
   1.375 +</div>
   1.376 +</div>
   1.377 +<a id="a660ef42520ed6737c2e77aae18e3a7a4"></a>
   1.378 +<h2 class="memtitle"><span class="permalink"><a href="#a660ef42520ed6737c2e77aae18e3a7a4">&#9670;&nbsp;</a></span>ucx_mempool_realloc()</h2>
   1.379 +
   1.380 +<div class="memitem">
   1.381 +<div class="memproto">
   1.382 +      <table class="memname">
   1.383 +        <tr>
   1.384 +          <td class="memname">void* ucx_mempool_realloc </td>
   1.385 +          <td>(</td>
   1.386 +          <td class="paramtype"><a class="el" href="structUcxMempool.html">UcxMempool</a> *&#160;</td>
   1.387 +          <td class="paramname"><em>pool</em>, </td>
   1.388 +        </tr>
   1.389 +        <tr>
   1.390 +          <td class="paramkey"></td>
   1.391 +          <td></td>
   1.392 +          <td class="paramtype">void *&#160;</td>
   1.393 +          <td class="paramname"><em>ptr</em>, </td>
   1.394 +        </tr>
   1.395 +        <tr>
   1.396 +          <td class="paramkey"></td>
   1.397 +          <td></td>
   1.398 +          <td class="paramtype">size_t&#160;</td>
   1.399 +          <td class="paramname"><em>n</em>&#160;</td>
   1.400 +        </tr>
   1.401 +        <tr>
   1.402 +          <td></td>
   1.403 +          <td>)</td>
   1.404 +          <td></td><td></td>
   1.405 +        </tr>
   1.406 +      </table>
   1.407 +</div><div class="memdoc">
   1.408 +
   1.409 +<p>Reallocates pooled memory. </p>
   1.410 +<p>If the memory to be reallocated is not contained by the specified pool, the behavior is undefined.</p>
   1.411 +<dl class="params"><dt>Parameters</dt><dd>
   1.412 +  <table class="params">
   1.413 +    <tr><td class="paramname">pool</td><td>the memory pool </td></tr>
   1.414 +    <tr><td class="paramname">ptr</td><td>a pointer to the memory that shall be reallocated </td></tr>
   1.415 +    <tr><td class="paramname">n</td><td>the new size of the memory </td></tr>
   1.416 +  </table>
   1.417 +  </dd>
   1.418 +</dl>
   1.419 +<dl class="section return"><dt>Returns</dt><dd>a pointer to the new location of the memory </dd></dl>
   1.420 +<dl class="section see"><dt>See also</dt><dd><a class="el" href="allocator_8h.html#a6d7cf038a806e327c5da37321d04e426" title="A function pointer to the allocators realloc() function. ">ucx_allocator_realloc()</a> </dd></dl>
   1.421 +
   1.422 +</div>
   1.423 +</div>
   1.424 +<a id="af47b6b7c40f8f263dc28cc9a4e77b27c"></a>
   1.425 +<h2 class="memtitle"><span class="permalink"><a href="#af47b6b7c40f8f263dc28cc9a4e77b27c">&#9670;&nbsp;</a></span>ucx_mempool_reg_destr()</h2>
   1.426 +
   1.427 +<div class="memitem">
   1.428 +<div class="memproto">
   1.429 +      <table class="memname">
   1.430 +        <tr>
   1.431 +          <td class="memname">void ucx_mempool_reg_destr </td>
   1.432 +          <td>(</td>
   1.433 +          <td class="paramtype"><a class="el" href="structUcxMempool.html">UcxMempool</a> *&#160;</td>
   1.434 +          <td class="paramname"><em>pool</em>, </td>
   1.435 +        </tr>
   1.436 +        <tr>
   1.437 +          <td class="paramkey"></td>
   1.438 +          <td></td>
   1.439 +          <td class="paramtype">void *&#160;</td>
   1.440 +          <td class="paramname"><em>ptr</em>, </td>
   1.441 +        </tr>
   1.442 +        <tr>
   1.443 +          <td class="paramkey"></td>
   1.444 +          <td></td>
   1.445 +          <td class="paramtype"><a class="el" href="ucx_8h.html#ad2b370c2809914c8b7fedab163c266b3">ucx_destructor</a>&#160;</td>
   1.446 +          <td class="paramname"><em>destr</em>&#160;</td>
   1.447 +        </tr>
   1.448 +        <tr>
   1.449 +          <td></td>
   1.450 +          <td>)</td>
   1.451 +          <td></td><td></td>
   1.452 +        </tr>
   1.453 +      </table>
   1.454 +</div><div class="memdoc">
   1.455 +
   1.456 +<p>Registers a destructor function for the specified (non-pooled) memory. </p>
   1.457 +<p>This is useful, if you have memory that has not been allocated by a mempool, but shall be managed by a mempool.</p>
   1.458 +<p>This function creates an entry in the specified mempool and the memory will therefore (logically) convert to pooled memory. <b>However, this does not cause the memory to be freed automatically!</b>. If you want to use this function, make the memory pool free non-pooled memory, the specified destructor function must call <code>free()</code> by itself. But keep in mind, that you then MUST NOT use this destructor function with pooled memory (e.g. in <a class="el" href="mempool_8h.html#adb788e7ec24cd7dbdea6381539c549f2" title="Sets a destructor function for the specified memory. ">ucx_mempool_set_destr()</a>), as it would cause a double-free.</p>
   1.459 +<dl class="params"><dt>Parameters</dt><dd>
   1.460 +  <table class="params">
   1.461 +    <tr><td class="paramname">pool</td><td>the memory pool </td></tr>
   1.462 +    <tr><td class="paramname">ptr</td><td>data the destructor is registered for </td></tr>
   1.463 +    <tr><td class="paramname">destr</td><td>a pointer to the destructor function </td></tr>
   1.464 +  </table>
   1.465 +  </dd>
   1.466 +</dl>
   1.467 +
   1.468 +</div>
   1.469 +</div>
   1.470 +<a id="adb788e7ec24cd7dbdea6381539c549f2"></a>
   1.471 +<h2 class="memtitle"><span class="permalink"><a href="#adb788e7ec24cd7dbdea6381539c549f2">&#9670;&nbsp;</a></span>ucx_mempool_set_destr()</h2>
   1.472 +
   1.473 +<div class="memitem">
   1.474 +<div class="memproto">
   1.475 +      <table class="memname">
   1.476 +        <tr>
   1.477 +          <td class="memname">void ucx_mempool_set_destr </td>
   1.478 +          <td>(</td>
   1.479 +          <td class="paramtype">void *&#160;</td>
   1.480 +          <td class="paramname"><em>ptr</em>, </td>
   1.481 +        </tr>
   1.482 +        <tr>
   1.483 +          <td class="paramkey"></td>
   1.484 +          <td></td>
   1.485 +          <td class="paramtype"><a class="el" href="ucx_8h.html#ad2b370c2809914c8b7fedab163c266b3">ucx_destructor</a>&#160;</td>
   1.486 +          <td class="paramname"><em>func</em>&#160;</td>
   1.487 +        </tr>
   1.488 +        <tr>
   1.489 +          <td></td>
   1.490 +          <td>)</td>
   1.491 +          <td></td><td></td>
   1.492 +        </tr>
   1.493 +      </table>
   1.494 +</div><div class="memdoc">
   1.495 +
   1.496 +<p>Sets a destructor function for the specified memory. </p>
   1.497 +<p>The destructor is automatically called when the memory is freed or the pool is destroyed. A destructor for pooled memory <b>MUST NOT</b> free the memory itself, as this is done by the pool. Use a destructor to free any resources managed by the pooled object.</p>
   1.498 +<p>The only requirement for the specified memory is, that it <b>MUST</b> be pooled memory by a <a class="el" href="structUcxMempool.html" title="UCX mempool structure. ">UcxMempool</a> or an element-compatible mempool. The pointer to the destructor function is saved in a reserved area before the actual memory.</p>
   1.499 +<dl class="params"><dt>Parameters</dt><dd>
   1.500 +  <table class="params">
   1.501 +    <tr><td class="paramname">ptr</td><td>pooled memory </td></tr>
   1.502 +    <tr><td class="paramname">func</td><td>a pointer to the destructor function </td></tr>
   1.503 +  </table>
   1.504 +  </dd>
   1.505 +</dl>
   1.506 +<dl class="section see"><dt>See also</dt><dd><a class="el" href="mempool_8h.html#aefa26e3015f5aefadbfc74221bd246ac" title="Frees pooled memory. ">ucx_mempool_free()</a> </dd>
   1.507 +<dd>
   1.508 +<a class="el" href="mempool_8h.html#af096378da7e9bfbed3088497cf4c15bf" title="Destroys a memory pool. ">ucx_mempool_destroy()</a> </dd></dl>
   1.509 +
   1.510 +</div>
   1.511 +</div>
   1.512 +</div><!-- contents -->
   1.513 +<!-- start footer part -->
   1.514 +<hr class="footer"/><address class="footer"><small>
   1.515 +Generated on Thu Dec 19 2019 19:58:24 for ucx by &#160;<a href="http://www.doxygen.org/index.html">
   1.516 +<img class="footer" src="doxygen.png" alt="doxygen"/>
   1.517 +</a> 1.8.13
   1.518 +</small></address>
   1.519 +</body>
   1.520 +</html>

mercurial