docs/api-2.1/mempool_8h.html

Sat, 23 Nov 2024 15:15:09 +0100

author
Mike Becker <universe@uap-core.de>
date
Sat, 23 Nov 2024 15:15:09 +0100
changeset 990
f708863e7ec6
parent 390
d345541018fa
permissions
-rw-r--r--

automatically disable szmul builtin when testing with coverage

<!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"/>
<meta name="generator" content="Doxygen 1.8.13"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>ucx: /home/mike/workspace/c/ucx/src/ucx/mempool.h File Reference</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td id="projectlogo"><img alt="Logo" src="uaplogo.png"/></td>
  <td id="projectalign" style="padding-left: 0.5em;">
   <div id="projectname">ucx
   </div>
   <div id="projectbrief">UAP Common Extensions</div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.13 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search",false,'Search');
</script>
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
$(function() {
  initMenu('',true,false,'search.php','Search');
  $(document).ready(function() { init_search(); });
});
</script>
<div id="main-nav"></div>
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div id="nav-path" class="navpath">
  <ul>
<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>
</div>
</div><!-- top -->
<div class="header">
  <div class="summary">
<a href="#nested-classes">Data Structures</a> &#124;
<a href="#define-members">Macros</a> &#124;
<a href="#func-members">Functions</a>  </div>
  <div class="headertitle">
<div class="title">mempool.h File Reference</div>  </div>
</div><!--header-->
<div class="contents">

<p>Memory pool implementation.  
<a href="#details">More...</a></p>
<div class="textblock"><code>#include &quot;<a class="el" href="ucx_8h_source.html">ucx.h</a>&quot;</code><br />
<code>#include &quot;<a class="el" href="allocator_8h_source.html">allocator.h</a>&quot;</code><br />
<code>#include &lt;stddef.h&gt;</code><br />
</div>
<p><a href="mempool_8h_source.html">Go to the source code of this file.</a></p>
<table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="nested-classes"></a>
Data Structures</h2></td></tr>
<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>
<tr class="memdesc:"><td class="mdescLeft">&#160;</td><td class="mdescRight">UCX mempool structure.  <a href="structUcxMempool.html#details">More...</a><br /></td></tr>
<tr class="separator:"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="define-members"></a>
Macros</h2></td></tr>
<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>
<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>
<tr class="separator:a49f7bd1da5ac201d0cf54dc0f0d82dd2"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="func-members"></a>
Functions</h2></td></tr>
<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>
<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>
<tr class="separator:ad71cb8c3b6fdb30360376a8b372ef22a"><td class="memSeparator" colspan="2">&#160;</td></tr>
<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>
<tr class="memdesc:aaf75b5016098723a9280531ccc3a6d77"><td class="mdescLeft">&#160;</td><td class="mdescRight">Resizes a memory pool.  <a href="#aaf75b5016098723a9280531ccc3a6d77">More...</a><br /></td></tr>
<tr class="separator:aaf75b5016098723a9280531ccc3a6d77"><td class="memSeparator" colspan="2">&#160;</td></tr>
<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>
<tr class="memdesc:a2ae492b8f2878ccc9837ac213dced11e"><td class="mdescLeft">&#160;</td><td class="mdescRight">Allocates pooled memory.  <a href="#a2ae492b8f2878ccc9837ac213dced11e">More...</a><br /></td></tr>
<tr class="separator:a2ae492b8f2878ccc9837ac213dced11e"><td class="memSeparator" colspan="2">&#160;</td></tr>
<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>
<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>
<tr class="separator:a4b9142011824ae24f00fabe128417d69"><td class="memSeparator" colspan="2">&#160;</td></tr>
<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>
<tr class="memdesc:a660ef42520ed6737c2e77aae18e3a7a4"><td class="mdescLeft">&#160;</td><td class="mdescRight">Reallocates pooled memory.  <a href="#a660ef42520ed6737c2e77aae18e3a7a4">More...</a><br /></td></tr>
<tr class="separator:a660ef42520ed6737c2e77aae18e3a7a4"><td class="memSeparator" colspan="2">&#160;</td></tr>
<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>
<tr class="memdesc:aefa26e3015f5aefadbfc74221bd246ac"><td class="mdescLeft">&#160;</td><td class="mdescRight">Frees pooled memory.  <a href="#aefa26e3015f5aefadbfc74221bd246ac">More...</a><br /></td></tr>
<tr class="separator:aefa26e3015f5aefadbfc74221bd246ac"><td class="memSeparator" colspan="2">&#160;</td></tr>
<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>
<tr class="memdesc:af096378da7e9bfbed3088497cf4c15bf"><td class="mdescLeft">&#160;</td><td class="mdescRight">Destroys a memory pool.  <a href="#af096378da7e9bfbed3088497cf4c15bf">More...</a><br /></td></tr>
<tr class="separator:af096378da7e9bfbed3088497cf4c15bf"><td class="memSeparator" colspan="2">&#160;</td></tr>
<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>
<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>
<tr class="separator:adb788e7ec24cd7dbdea6381539c549f2"><td class="memSeparator" colspan="2">&#160;</td></tr>
<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>
<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>
<tr class="separator:af47b6b7c40f8f263dc28cc9a4e77b27c"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table>
<a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2>
<div class="textblock"><p>Memory pool implementation. </p>
<dl class="section author"><dt>Author</dt><dd>Mike Becker </dd>
<dd>
Olaf Wintermann </dd></dl>
</div><h2 class="groupheader">Macro Definition Documentation</h2>
<a id="a49f7bd1da5ac201d0cf54dc0f0d82dd2"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a49f7bd1da5ac201d0cf54dc0f0d82dd2">&#9670;&nbsp;</a></span>ucx_mempool_new_default</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">#define ucx_mempool_new_default</td>
          <td>(</td>
          <td class="paramname"></td><td>)</td>
          <td>&#160;&#160;&#160;<a class="el" href="mempool_8h.html#ad71cb8c3b6fdb30360376a8b372ef22a">ucx_mempool_new</a>(16)</td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Shorthand for a new default memory pool with a capacity of 16 elements. </p>

</div>
</div>
<h2 class="groupheader">Function Documentation</h2>
<a id="a4b9142011824ae24f00fabe128417d69"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a4b9142011824ae24f00fabe128417d69">&#9670;&nbsp;</a></span>ucx_mempool_calloc()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void* ucx_mempool_calloc </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structUcxMempool.html">UcxMempool</a> *&#160;</td>
          <td class="paramname"><em>pool</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">size_t&#160;</td>
          <td class="paramname"><em>nelem</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">size_t&#160;</td>
          <td class="paramname"><em>elsize</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Allocates a pooled memory array. </p>
<p>The content of the allocated memory is set to zero.</p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">pool</td><td>the memory pool </td></tr>
    <tr><td class="paramname">nelem</td><td>amount of elements to allocate </td></tr>
    <tr><td class="paramname">elsize</td><td>amount of memory per element </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>a pointer to the allocated memory </dd></dl>
<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>

</div>
</div>
<a id="aaf75b5016098723a9280531ccc3a6d77"></a>
<h2 class="memtitle"><span class="permalink"><a href="#aaf75b5016098723a9280531ccc3a6d77">&#9670;&nbsp;</a></span>ucx_mempool_chcap()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">int ucx_mempool_chcap </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structUcxMempool.html">UcxMempool</a> *&#160;</td>
          <td class="paramname"><em>pool</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">size_t&#160;</td>
          <td class="paramname"><em>newcap</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Resizes a memory pool. </p>
<p>This function will fail if the new capacity is not sufficient for the present data.</p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">pool</td><td>the pool to resize </td></tr>
    <tr><td class="paramname">newcap</td><td>the new capacity </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>zero on success or non-zero on failure </dd></dl>

</div>
</div>
<a id="af096378da7e9bfbed3088497cf4c15bf"></a>
<h2 class="memtitle"><span class="permalink"><a href="#af096378da7e9bfbed3088497cf4c15bf">&#9670;&nbsp;</a></span>ucx_mempool_destroy()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void ucx_mempool_destroy </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structUcxMempool.html">UcxMempool</a> *&#160;</td>
          <td class="paramname"><em>pool</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Destroys a memory pool. </p>
<p>For each element the destructor function (if any) is called and the element is freed.</p>
<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>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">pool</td><td>the mempool to destroy </td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
<a id="aefa26e3015f5aefadbfc74221bd246ac"></a>
<h2 class="memtitle"><span class="permalink"><a href="#aefa26e3015f5aefadbfc74221bd246ac">&#9670;&nbsp;</a></span>ucx_mempool_free()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void ucx_mempool_free </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structUcxMempool.html">UcxMempool</a> *&#160;</td>
          <td class="paramname"><em>pool</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">void *&#160;</td>
          <td class="paramname"><em>ptr</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Frees pooled memory. </p>
<p>Before freeing the memory, the specified destructor function (if any) is called.</p>
<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>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">pool</td><td>the memory pool </td></tr>
    <tr><td class="paramname">ptr</td><td>a pointer to the memory that shall be freed </td></tr>
  </table>
  </dd>
</dl>
<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>

</div>
</div>
<a id="a2ae492b8f2878ccc9837ac213dced11e"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a2ae492b8f2878ccc9837ac213dced11e">&#9670;&nbsp;</a></span>ucx_mempool_malloc()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void* ucx_mempool_malloc </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structUcxMempool.html">UcxMempool</a> *&#160;</td>
          <td class="paramname"><em>pool</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">size_t&#160;</td>
          <td class="paramname"><em>n</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Allocates pooled memory. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">pool</td><td>the memory pool </td></tr>
    <tr><td class="paramname">n</td><td>amount of memory to allocate </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>a pointer to the allocated memory </dd></dl>
<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>

</div>
</div>
<a id="ad71cb8c3b6fdb30360376a8b372ef22a"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ad71cb8c3b6fdb30360376a8b372ef22a">&#9670;&nbsp;</a></span>ucx_mempool_new()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="structUcxMempool.html">UcxMempool</a>* ucx_mempool_new </td>
          <td>(</td>
          <td class="paramtype">size_t&#160;</td>
          <td class="paramname"><em>n</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Creates a memory pool with the specified initial size. </p>
<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>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">n</td><td>initial pool size (should be a power of two, e.g. 16) </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>a pointer to the new memory pool </dd></dl>
<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>

</div>
</div>
<a id="a660ef42520ed6737c2e77aae18e3a7a4"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a660ef42520ed6737c2e77aae18e3a7a4">&#9670;&nbsp;</a></span>ucx_mempool_realloc()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void* ucx_mempool_realloc </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structUcxMempool.html">UcxMempool</a> *&#160;</td>
          <td class="paramname"><em>pool</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">void *&#160;</td>
          <td class="paramname"><em>ptr</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">size_t&#160;</td>
          <td class="paramname"><em>n</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Reallocates pooled memory. </p>
<p>If the memory to be reallocated is not contained by the specified pool, the behavior is undefined.</p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">pool</td><td>the memory pool </td></tr>
    <tr><td class="paramname">ptr</td><td>a pointer to the memory that shall be reallocated </td></tr>
    <tr><td class="paramname">n</td><td>the new size of the memory </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>a pointer to the new location of the memory </dd></dl>
<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>

</div>
</div>
<a id="af47b6b7c40f8f263dc28cc9a4e77b27c"></a>
<h2 class="memtitle"><span class="permalink"><a href="#af47b6b7c40f8f263dc28cc9a4e77b27c">&#9670;&nbsp;</a></span>ucx_mempool_reg_destr()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void ucx_mempool_reg_destr </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structUcxMempool.html">UcxMempool</a> *&#160;</td>
          <td class="paramname"><em>pool</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">void *&#160;</td>
          <td class="paramname"><em>ptr</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="ucx_8h.html#ad2b370c2809914c8b7fedab163c266b3">ucx_destructor</a>&#160;</td>
          <td class="paramname"><em>destr</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Registers a destructor function for the specified (non-pooled) memory. </p>
<p>This is useful, if you have memory that has not been allocated by a mempool, but shall be managed by a mempool.</p>
<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>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">pool</td><td>the memory pool </td></tr>
    <tr><td class="paramname">ptr</td><td>data the destructor is registered for </td></tr>
    <tr><td class="paramname">destr</td><td>a pointer to the destructor function </td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
<a id="adb788e7ec24cd7dbdea6381539c549f2"></a>
<h2 class="memtitle"><span class="permalink"><a href="#adb788e7ec24cd7dbdea6381539c549f2">&#9670;&nbsp;</a></span>ucx_mempool_set_destr()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void ucx_mempool_set_destr </td>
          <td>(</td>
          <td class="paramtype">void *&#160;</td>
          <td class="paramname"><em>ptr</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="ucx_8h.html#ad2b370c2809914c8b7fedab163c266b3">ucx_destructor</a>&#160;</td>
          <td class="paramname"><em>func</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Sets a destructor function for the specified memory. </p>
<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>
<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>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">ptr</td><td>pooled memory </td></tr>
    <tr><td class="paramname">func</td><td>a pointer to the destructor function </td></tr>
  </table>
  </dd>
</dl>
<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>
<dd>
<a class="el" href="mempool_8h.html#af096378da7e9bfbed3088497cf4c15bf" title="Destroys a memory pool. ">ucx_mempool_destroy()</a> </dd></dl>

</div>
</div>
</div><!-- contents -->
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
Generated on Thu Dec 19 2019 19:58:24 for ucx by &#160;<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/>
</a> 1.8.13
</small></address>
</body>
</html>

mercurial