Tue, 20 Aug 2024 13:53:18 +0200
remove condition that is always false after recent fix
390 | 1 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
2 | <html xmlns="http://www.w3.org/1999/xhtml"> | |
3 | <head> | |
4 | <meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/> | |
5 | <meta http-equiv="X-UA-Compatible" content="IE=9"/> | |
6 | <meta name="generator" content="Doxygen 1.8.13"/> | |
7 | <meta name="viewport" content="width=device-width, initial-scale=1"/> | |
8 | <title>ucx: /home/mike/workspace/c/ucx/src/ucx/mempool.h File Reference</title> | |
9 | <link href="tabs.css" rel="stylesheet" type="text/css"/> | |
10 | <script type="text/javascript" src="jquery.js"></script> | |
11 | <script type="text/javascript" src="dynsections.js"></script> | |
12 | <link href="search/search.css" rel="stylesheet" type="text/css"/> | |
13 | <script type="text/javascript" src="search/searchdata.js"></script> | |
14 | <script type="text/javascript" src="search/search.js"></script> | |
15 | <link href="doxygen.css" rel="stylesheet" type="text/css" /> | |
16 | </head> | |
17 | <body> | |
18 | <div id="top"><!-- do not remove this div, it is closed by doxygen! --> | |
19 | <div id="titlearea"> | |
20 | <table cellspacing="0" cellpadding="0"> | |
21 | <tbody> | |
22 | <tr style="height: 56px;"> | |
23 | <td id="projectlogo"><img alt="Logo" src="uaplogo.png"/></td> | |
24 | <td id="projectalign" style="padding-left: 0.5em;"> | |
25 | <div id="projectname">ucx | |
26 | </div> | |
27 | <div id="projectbrief">UAP Common Extensions</div> | |
28 | </td> | |
29 | </tr> | |
30 | </tbody> | |
31 | </table> | |
32 | </div> | |
33 | <!-- end header part --> | |
34 | <!-- Generated by Doxygen 1.8.13 --> | |
35 | <script type="text/javascript"> | |
36 | var searchBox = new SearchBox("searchBox", "search",false,'Search'); | |
37 | </script> | |
38 | <script type="text/javascript" src="menudata.js"></script> | |
39 | <script type="text/javascript" src="menu.js"></script> | |
40 | <script type="text/javascript"> | |
41 | $(function() { | |
42 | initMenu('',true,false,'search.php','Search'); | |
43 | $(document).ready(function() { init_search(); }); | |
44 | }); | |
45 | </script> | |
46 | <div id="main-nav"></div> | |
47 | <!-- window showing the filter options --> | |
48 | <div id="MSearchSelectWindow" | |
49 | onmouseover="return searchBox.OnSearchSelectShow()" | |
50 | onmouseout="return searchBox.OnSearchSelectHide()" | |
51 | onkeydown="return searchBox.OnSearchSelectKey(event)"> | |
52 | </div> | |
53 | ||
54 | <!-- iframe showing the search results (closed by default) --> | |
55 | <div id="MSearchResultsWindow"> | |
56 | <iframe src="javascript:void(0)" frameborder="0" | |
57 | name="MSearchResults" id="MSearchResults"> | |
58 | </iframe> | |
59 | </div> | |
60 | ||
61 | <div id="nav-path" class="navpath"> | |
62 | <ul> | |
63 | <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> | |
64 | </div> | |
65 | </div><!-- top --> | |
66 | <div class="header"> | |
67 | <div class="summary"> | |
68 | <a href="#nested-classes">Data Structures</a> | | |
69 | <a href="#define-members">Macros</a> | | |
70 | <a href="#func-members">Functions</a> </div> | |
71 | <div class="headertitle"> | |
72 | <div class="title">mempool.h File Reference</div> </div> | |
73 | </div><!--header--> | |
74 | <div class="contents"> | |
75 | ||
76 | <p>Memory pool implementation. | |
77 | <a href="#details">More...</a></p> | |
78 | <div class="textblock"><code>#include "<a class="el" href="ucx_8h_source.html">ucx.h</a>"</code><br /> | |
79 | <code>#include "<a class="el" href="allocator_8h_source.html">allocator.h</a>"</code><br /> | |
80 | <code>#include <stddef.h></code><br /> | |
81 | </div> | |
82 | <p><a href="mempool_8h_source.html">Go to the source code of this file.</a></p> | |
83 | <table class="memberdecls"> | |
84 | <tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="nested-classes"></a> | |
85 | Data Structures</h2></td></tr> | |
86 | <tr class="memitem:"><td class="memItemLeft" align="right" valign="top">struct  </td><td class="memItemRight" valign="bottom"><a class="el" href="structUcxMempool.html">UcxMempool</a></td></tr> | |
87 | <tr class="memdesc:"><td class="mdescLeft"> </td><td class="mdescRight">UCX mempool structure. <a href="structUcxMempool.html#details">More...</a><br /></td></tr> | |
88 | <tr class="separator:"><td class="memSeparator" colspan="2"> </td></tr> | |
89 | </table><table class="memberdecls"> | |
90 | <tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="define-members"></a> | |
91 | Macros</h2></td></tr> | |
92 | <tr class="memitem:a49f7bd1da5ac201d0cf54dc0f0d82dd2"><td class="memItemLeft" align="right" valign="top">#define </td><td class="memItemRight" valign="bottom"><a class="el" href="mempool_8h.html#a49f7bd1da5ac201d0cf54dc0f0d82dd2">ucx_mempool_new_default</a>()   <a class="el" href="mempool_8h.html#ad71cb8c3b6fdb30360376a8b372ef22a">ucx_mempool_new</a>(16)</td></tr> | |
93 | <tr class="memdesc:a49f7bd1da5ac201d0cf54dc0f0d82dd2"><td class="mdescLeft"> </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> | |
94 | <tr class="separator:a49f7bd1da5ac201d0cf54dc0f0d82dd2"><td class="memSeparator" colspan="2"> </td></tr> | |
95 | </table><table class="memberdecls"> | |
96 | <tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="func-members"></a> | |
97 | Functions</h2></td></tr> | |
98 | <tr class="memitem:ad71cb8c3b6fdb30360376a8b372ef22a"><td class="memItemLeft" align="right" valign="top"><a class="el" href="structUcxMempool.html">UcxMempool</a> * </td><td class="memItemRight" valign="bottom"><a class="el" href="mempool_8h.html#ad71cb8c3b6fdb30360376a8b372ef22a">ucx_mempool_new</a> (size_t n)</td></tr> | |
99 | <tr class="memdesc:ad71cb8c3b6fdb30360376a8b372ef22a"><td class="mdescLeft"> </td><td class="mdescRight">Creates a memory pool with the specified initial size. <a href="#ad71cb8c3b6fdb30360376a8b372ef22a">More...</a><br /></td></tr> | |
100 | <tr class="separator:ad71cb8c3b6fdb30360376a8b372ef22a"><td class="memSeparator" colspan="2"> </td></tr> | |
101 | <tr class="memitem:aaf75b5016098723a9280531ccc3a6d77"><td class="memItemLeft" align="right" valign="top">int </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> | |
102 | <tr class="memdesc:aaf75b5016098723a9280531ccc3a6d77"><td class="mdescLeft"> </td><td class="mdescRight">Resizes a memory pool. <a href="#aaf75b5016098723a9280531ccc3a6d77">More...</a><br /></td></tr> | |
103 | <tr class="separator:aaf75b5016098723a9280531ccc3a6d77"><td class="memSeparator" colspan="2"> </td></tr> | |
104 | <tr class="memitem:a2ae492b8f2878ccc9837ac213dced11e"><td class="memItemLeft" align="right" valign="top">void * </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> | |
105 | <tr class="memdesc:a2ae492b8f2878ccc9837ac213dced11e"><td class="mdescLeft"> </td><td class="mdescRight">Allocates pooled memory. <a href="#a2ae492b8f2878ccc9837ac213dced11e">More...</a><br /></td></tr> | |
106 | <tr class="separator:a2ae492b8f2878ccc9837ac213dced11e"><td class="memSeparator" colspan="2"> </td></tr> | |
107 | <tr class="memitem:a4b9142011824ae24f00fabe128417d69"><td class="memItemLeft" align="right" valign="top">void * </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> | |
108 | <tr class="memdesc:a4b9142011824ae24f00fabe128417d69"><td class="mdescLeft"> </td><td class="mdescRight">Allocates a pooled memory array. <a href="#a4b9142011824ae24f00fabe128417d69">More...</a><br /></td></tr> | |
109 | <tr class="separator:a4b9142011824ae24f00fabe128417d69"><td class="memSeparator" colspan="2"> </td></tr> | |
110 | <tr class="memitem:a660ef42520ed6737c2e77aae18e3a7a4"><td class="memItemLeft" align="right" valign="top">void * </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> | |
111 | <tr class="memdesc:a660ef42520ed6737c2e77aae18e3a7a4"><td class="mdescLeft"> </td><td class="mdescRight">Reallocates pooled memory. <a href="#a660ef42520ed6737c2e77aae18e3a7a4">More...</a><br /></td></tr> | |
112 | <tr class="separator:a660ef42520ed6737c2e77aae18e3a7a4"><td class="memSeparator" colspan="2"> </td></tr> | |
113 | <tr class="memitem:aefa26e3015f5aefadbfc74221bd246ac"><td class="memItemLeft" align="right" valign="top">void </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> | |
114 | <tr class="memdesc:aefa26e3015f5aefadbfc74221bd246ac"><td class="mdescLeft"> </td><td class="mdescRight">Frees pooled memory. <a href="#aefa26e3015f5aefadbfc74221bd246ac">More...</a><br /></td></tr> | |
115 | <tr class="separator:aefa26e3015f5aefadbfc74221bd246ac"><td class="memSeparator" colspan="2"> </td></tr> | |
116 | <tr class="memitem:af096378da7e9bfbed3088497cf4c15bf"><td class="memItemLeft" align="right" valign="top">void </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> | |
117 | <tr class="memdesc:af096378da7e9bfbed3088497cf4c15bf"><td class="mdescLeft"> </td><td class="mdescRight">Destroys a memory pool. <a href="#af096378da7e9bfbed3088497cf4c15bf">More...</a><br /></td></tr> | |
118 | <tr class="separator:af096378da7e9bfbed3088497cf4c15bf"><td class="memSeparator" colspan="2"> </td></tr> | |
119 | <tr class="memitem:adb788e7ec24cd7dbdea6381539c549f2"><td class="memItemLeft" align="right" valign="top">void </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> | |
120 | <tr class="memdesc:adb788e7ec24cd7dbdea6381539c549f2"><td class="mdescLeft"> </td><td class="mdescRight">Sets a destructor function for the specified memory. <a href="#adb788e7ec24cd7dbdea6381539c549f2">More...</a><br /></td></tr> | |
121 | <tr class="separator:adb788e7ec24cd7dbdea6381539c549f2"><td class="memSeparator" colspan="2"> </td></tr> | |
122 | <tr class="memitem:af47b6b7c40f8f263dc28cc9a4e77b27c"><td class="memItemLeft" align="right" valign="top">void </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> | |
123 | <tr class="memdesc:af47b6b7c40f8f263dc28cc9a4e77b27c"><td class="mdescLeft"> </td><td class="mdescRight">Registers a destructor function for the specified (non-pooled) memory. <a href="#af47b6b7c40f8f263dc28cc9a4e77b27c">More...</a><br /></td></tr> | |
124 | <tr class="separator:af47b6b7c40f8f263dc28cc9a4e77b27c"><td class="memSeparator" colspan="2"> </td></tr> | |
125 | </table> | |
126 | <a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2> | |
127 | <div class="textblock"><p>Memory pool implementation. </p> | |
128 | <dl class="section author"><dt>Author</dt><dd>Mike Becker </dd> | |
129 | <dd> | |
130 | Olaf Wintermann </dd></dl> | |
131 | </div><h2 class="groupheader">Macro Definition Documentation</h2> | |
132 | <a id="a49f7bd1da5ac201d0cf54dc0f0d82dd2"></a> | |
133 | <h2 class="memtitle"><span class="permalink"><a href="#a49f7bd1da5ac201d0cf54dc0f0d82dd2">◆ </a></span>ucx_mempool_new_default</h2> | |
134 | ||
135 | <div class="memitem"> | |
136 | <div class="memproto"> | |
137 | <table class="memname"> | |
138 | <tr> | |
139 | <td class="memname">#define ucx_mempool_new_default</td> | |
140 | <td>(</td> | |
141 | <td class="paramname"></td><td>)</td> | |
142 | <td>   <a class="el" href="mempool_8h.html#ad71cb8c3b6fdb30360376a8b372ef22a">ucx_mempool_new</a>(16)</td> | |
143 | </tr> | |
144 | </table> | |
145 | </div><div class="memdoc"> | |
146 | ||
147 | <p>Shorthand for a new default memory pool with a capacity of 16 elements. </p> | |
148 | ||
149 | </div> | |
150 | </div> | |
151 | <h2 class="groupheader">Function Documentation</h2> | |
152 | <a id="a4b9142011824ae24f00fabe128417d69"></a> | |
153 | <h2 class="memtitle"><span class="permalink"><a href="#a4b9142011824ae24f00fabe128417d69">◆ </a></span>ucx_mempool_calloc()</h2> | |
154 | ||
155 | <div class="memitem"> | |
156 | <div class="memproto"> | |
157 | <table class="memname"> | |
158 | <tr> | |
159 | <td class="memname">void* ucx_mempool_calloc </td> | |
160 | <td>(</td> | |
161 | <td class="paramtype"><a class="el" href="structUcxMempool.html">UcxMempool</a> * </td> | |
162 | <td class="paramname"><em>pool</em>, </td> | |
163 | </tr> | |
164 | <tr> | |
165 | <td class="paramkey"></td> | |
166 | <td></td> | |
167 | <td class="paramtype">size_t </td> | |
168 | <td class="paramname"><em>nelem</em>, </td> | |
169 | </tr> | |
170 | <tr> | |
171 | <td class="paramkey"></td> | |
172 | <td></td> | |
173 | <td class="paramtype">size_t </td> | |
174 | <td class="paramname"><em>elsize</em> </td> | |
175 | </tr> | |
176 | <tr> | |
177 | <td></td> | |
178 | <td>)</td> | |
179 | <td></td><td></td> | |
180 | </tr> | |
181 | </table> | |
182 | </div><div class="memdoc"> | |
183 | ||
184 | <p>Allocates a pooled memory array. </p> | |
185 | <p>The content of the allocated memory is set to zero.</p> | |
186 | <dl class="params"><dt>Parameters</dt><dd> | |
187 | <table class="params"> | |
188 | <tr><td class="paramname">pool</td><td>the memory pool </td></tr> | |
189 | <tr><td class="paramname">nelem</td><td>amount of elements to allocate </td></tr> | |
190 | <tr><td class="paramname">elsize</td><td>amount of memory per element </td></tr> | |
191 | </table> | |
192 | </dd> | |
193 | </dl> | |
194 | <dl class="section return"><dt>Returns</dt><dd>a pointer to the allocated memory </dd></dl> | |
195 | <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> | |
196 | ||
197 | </div> | |
198 | </div> | |
199 | <a id="aaf75b5016098723a9280531ccc3a6d77"></a> | |
200 | <h2 class="memtitle"><span class="permalink"><a href="#aaf75b5016098723a9280531ccc3a6d77">◆ </a></span>ucx_mempool_chcap()</h2> | |
201 | ||
202 | <div class="memitem"> | |
203 | <div class="memproto"> | |
204 | <table class="memname"> | |
205 | <tr> | |
206 | <td class="memname">int ucx_mempool_chcap </td> | |
207 | <td>(</td> | |
208 | <td class="paramtype"><a class="el" href="structUcxMempool.html">UcxMempool</a> * </td> | |
209 | <td class="paramname"><em>pool</em>, </td> | |
210 | </tr> | |
211 | <tr> | |
212 | <td class="paramkey"></td> | |
213 | <td></td> | |
214 | <td class="paramtype">size_t </td> | |
215 | <td class="paramname"><em>newcap</em> </td> | |
216 | </tr> | |
217 | <tr> | |
218 | <td></td> | |
219 | <td>)</td> | |
220 | <td></td><td></td> | |
221 | </tr> | |
222 | </table> | |
223 | </div><div class="memdoc"> | |
224 | ||
225 | <p>Resizes a memory pool. </p> | |
226 | <p>This function will fail if the new capacity is not sufficient for the present data.</p> | |
227 | <dl class="params"><dt>Parameters</dt><dd> | |
228 | <table class="params"> | |
229 | <tr><td class="paramname">pool</td><td>the pool to resize </td></tr> | |
230 | <tr><td class="paramname">newcap</td><td>the new capacity </td></tr> | |
231 | </table> | |
232 | </dd> | |
233 | </dl> | |
234 | <dl class="section return"><dt>Returns</dt><dd>zero on success or non-zero on failure </dd></dl> | |
235 | ||
236 | </div> | |
237 | </div> | |
238 | <a id="af096378da7e9bfbed3088497cf4c15bf"></a> | |
239 | <h2 class="memtitle"><span class="permalink"><a href="#af096378da7e9bfbed3088497cf4c15bf">◆ </a></span>ucx_mempool_destroy()</h2> | |
240 | ||
241 | <div class="memitem"> | |
242 | <div class="memproto"> | |
243 | <table class="memname"> | |
244 | <tr> | |
245 | <td class="memname">void ucx_mempool_destroy </td> | |
246 | <td>(</td> | |
247 | <td class="paramtype"><a class="el" href="structUcxMempool.html">UcxMempool</a> * </td> | |
248 | <td class="paramname"><em>pool</em></td><td>)</td> | |
249 | <td></td> | |
250 | </tr> | |
251 | </table> | |
252 | </div><div class="memdoc"> | |
253 | ||
254 | <p>Destroys a memory pool. </p> | |
255 | <p>For each element the destructor function (if any) is called and the element is freed.</p> | |
256 | <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> | |
257 | <dl class="params"><dt>Parameters</dt><dd> | |
258 | <table class="params"> | |
259 | <tr><td class="paramname">pool</td><td>the mempool to destroy </td></tr> | |
260 | </table> | |
261 | </dd> | |
262 | </dl> | |
263 | ||
264 | </div> | |
265 | </div> | |
266 | <a id="aefa26e3015f5aefadbfc74221bd246ac"></a> | |
267 | <h2 class="memtitle"><span class="permalink"><a href="#aefa26e3015f5aefadbfc74221bd246ac">◆ </a></span>ucx_mempool_free()</h2> | |
268 | ||
269 | <div class="memitem"> | |
270 | <div class="memproto"> | |
271 | <table class="memname"> | |
272 | <tr> | |
273 | <td class="memname">void ucx_mempool_free </td> | |
274 | <td>(</td> | |
275 | <td class="paramtype"><a class="el" href="structUcxMempool.html">UcxMempool</a> * </td> | |
276 | <td class="paramname"><em>pool</em>, </td> | |
277 | </tr> | |
278 | <tr> | |
279 | <td class="paramkey"></td> | |
280 | <td></td> | |
281 | <td class="paramtype">void * </td> | |
282 | <td class="paramname"><em>ptr</em> </td> | |
283 | </tr> | |
284 | <tr> | |
285 | <td></td> | |
286 | <td>)</td> | |
287 | <td></td><td></td> | |
288 | </tr> | |
289 | </table> | |
290 | </div><div class="memdoc"> | |
291 | ||
292 | <p>Frees pooled memory. </p> | |
293 | <p>Before freeing the memory, the specified destructor function (if any) is called.</p> | |
294 | <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> | |
295 | <dl class="params"><dt>Parameters</dt><dd> | |
296 | <table class="params"> | |
297 | <tr><td class="paramname">pool</td><td>the memory pool </td></tr> | |
298 | <tr><td class="paramname">ptr</td><td>a pointer to the memory that shall be freed </td></tr> | |
299 | </table> | |
300 | </dd> | |
301 | </dl> | |
302 | <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> | |
303 | ||
304 | </div> | |
305 | </div> | |
306 | <a id="a2ae492b8f2878ccc9837ac213dced11e"></a> | |
307 | <h2 class="memtitle"><span class="permalink"><a href="#a2ae492b8f2878ccc9837ac213dced11e">◆ </a></span>ucx_mempool_malloc()</h2> | |
308 | ||
309 | <div class="memitem"> | |
310 | <div class="memproto"> | |
311 | <table class="memname"> | |
312 | <tr> | |
313 | <td class="memname">void* ucx_mempool_malloc </td> | |
314 | <td>(</td> | |
315 | <td class="paramtype"><a class="el" href="structUcxMempool.html">UcxMempool</a> * </td> | |
316 | <td class="paramname"><em>pool</em>, </td> | |
317 | </tr> | |
318 | <tr> | |
319 | <td class="paramkey"></td> | |
320 | <td></td> | |
321 | <td class="paramtype">size_t </td> | |
322 | <td class="paramname"><em>n</em> </td> | |
323 | </tr> | |
324 | <tr> | |
325 | <td></td> | |
326 | <td>)</td> | |
327 | <td></td><td></td> | |
328 | </tr> | |
329 | </table> | |
330 | </div><div class="memdoc"> | |
331 | ||
332 | <p>Allocates pooled memory. </p> | |
333 | <dl class="params"><dt>Parameters</dt><dd> | |
334 | <table class="params"> | |
335 | <tr><td class="paramname">pool</td><td>the memory pool </td></tr> | |
336 | <tr><td class="paramname">n</td><td>amount of memory to allocate </td></tr> | |
337 | </table> | |
338 | </dd> | |
339 | </dl> | |
340 | <dl class="section return"><dt>Returns</dt><dd>a pointer to the allocated memory </dd></dl> | |
341 | <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> | |
342 | ||
343 | </div> | |
344 | </div> | |
345 | <a id="ad71cb8c3b6fdb30360376a8b372ef22a"></a> | |
346 | <h2 class="memtitle"><span class="permalink"><a href="#ad71cb8c3b6fdb30360376a8b372ef22a">◆ </a></span>ucx_mempool_new()</h2> | |
347 | ||
348 | <div class="memitem"> | |
349 | <div class="memproto"> | |
350 | <table class="memname"> | |
351 | <tr> | |
352 | <td class="memname"><a class="el" href="structUcxMempool.html">UcxMempool</a>* ucx_mempool_new </td> | |
353 | <td>(</td> | |
354 | <td class="paramtype">size_t </td> | |
355 | <td class="paramname"><em>n</em></td><td>)</td> | |
356 | <td></td> | |
357 | </tr> | |
358 | </table> | |
359 | </div><div class="memdoc"> | |
360 | ||
361 | <p>Creates a memory pool with the specified initial size. </p> | |
362 | <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> | |
363 | <dl class="params"><dt>Parameters</dt><dd> | |
364 | <table class="params"> | |
365 | <tr><td class="paramname">n</td><td>initial pool size (should be a power of two, e.g. 16) </td></tr> | |
366 | </table> | |
367 | </dd> | |
368 | </dl> | |
369 | <dl class="section return"><dt>Returns</dt><dd>a pointer to the new memory pool </dd></dl> | |
370 | <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> | |
371 | ||
372 | </div> | |
373 | </div> | |
374 | <a id="a660ef42520ed6737c2e77aae18e3a7a4"></a> | |
375 | <h2 class="memtitle"><span class="permalink"><a href="#a660ef42520ed6737c2e77aae18e3a7a4">◆ </a></span>ucx_mempool_realloc()</h2> | |
376 | ||
377 | <div class="memitem"> | |
378 | <div class="memproto"> | |
379 | <table class="memname"> | |
380 | <tr> | |
381 | <td class="memname">void* ucx_mempool_realloc </td> | |
382 | <td>(</td> | |
383 | <td class="paramtype"><a class="el" href="structUcxMempool.html">UcxMempool</a> * </td> | |
384 | <td class="paramname"><em>pool</em>, </td> | |
385 | </tr> | |
386 | <tr> | |
387 | <td class="paramkey"></td> | |
388 | <td></td> | |
389 | <td class="paramtype">void * </td> | |
390 | <td class="paramname"><em>ptr</em>, </td> | |
391 | </tr> | |
392 | <tr> | |
393 | <td class="paramkey"></td> | |
394 | <td></td> | |
395 | <td class="paramtype">size_t </td> | |
396 | <td class="paramname"><em>n</em> </td> | |
397 | </tr> | |
398 | <tr> | |
399 | <td></td> | |
400 | <td>)</td> | |
401 | <td></td><td></td> | |
402 | </tr> | |
403 | </table> | |
404 | </div><div class="memdoc"> | |
405 | ||
406 | <p>Reallocates pooled memory. </p> | |
407 | <p>If the memory to be reallocated is not contained by the specified pool, the behavior is undefined.</p> | |
408 | <dl class="params"><dt>Parameters</dt><dd> | |
409 | <table class="params"> | |
410 | <tr><td class="paramname">pool</td><td>the memory pool </td></tr> | |
411 | <tr><td class="paramname">ptr</td><td>a pointer to the memory that shall be reallocated </td></tr> | |
412 | <tr><td class="paramname">n</td><td>the new size of the memory </td></tr> | |
413 | </table> | |
414 | </dd> | |
415 | </dl> | |
416 | <dl class="section return"><dt>Returns</dt><dd>a pointer to the new location of the memory </dd></dl> | |
417 | <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> | |
418 | ||
419 | </div> | |
420 | </div> | |
421 | <a id="af47b6b7c40f8f263dc28cc9a4e77b27c"></a> | |
422 | <h2 class="memtitle"><span class="permalink"><a href="#af47b6b7c40f8f263dc28cc9a4e77b27c">◆ </a></span>ucx_mempool_reg_destr()</h2> | |
423 | ||
424 | <div class="memitem"> | |
425 | <div class="memproto"> | |
426 | <table class="memname"> | |
427 | <tr> | |
428 | <td class="memname">void ucx_mempool_reg_destr </td> | |
429 | <td>(</td> | |
430 | <td class="paramtype"><a class="el" href="structUcxMempool.html">UcxMempool</a> * </td> | |
431 | <td class="paramname"><em>pool</em>, </td> | |
432 | </tr> | |
433 | <tr> | |
434 | <td class="paramkey"></td> | |
435 | <td></td> | |
436 | <td class="paramtype">void * </td> | |
437 | <td class="paramname"><em>ptr</em>, </td> | |
438 | </tr> | |
439 | <tr> | |
440 | <td class="paramkey"></td> | |
441 | <td></td> | |
442 | <td class="paramtype"><a class="el" href="ucx_8h.html#ad2b370c2809914c8b7fedab163c266b3">ucx_destructor</a> </td> | |
443 | <td class="paramname"><em>destr</em> </td> | |
444 | </tr> | |
445 | <tr> | |
446 | <td></td> | |
447 | <td>)</td> | |
448 | <td></td><td></td> | |
449 | </tr> | |
450 | </table> | |
451 | </div><div class="memdoc"> | |
452 | ||
453 | <p>Registers a destructor function for the specified (non-pooled) memory. </p> | |
454 | <p>This is useful, if you have memory that has not been allocated by a mempool, but shall be managed by a mempool.</p> | |
455 | <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> | |
456 | <dl class="params"><dt>Parameters</dt><dd> | |
457 | <table class="params"> | |
458 | <tr><td class="paramname">pool</td><td>the memory pool </td></tr> | |
459 | <tr><td class="paramname">ptr</td><td>data the destructor is registered for </td></tr> | |
460 | <tr><td class="paramname">destr</td><td>a pointer to the destructor function </td></tr> | |
461 | </table> | |
462 | </dd> | |
463 | </dl> | |
464 | ||
465 | </div> | |
466 | </div> | |
467 | <a id="adb788e7ec24cd7dbdea6381539c549f2"></a> | |
468 | <h2 class="memtitle"><span class="permalink"><a href="#adb788e7ec24cd7dbdea6381539c549f2">◆ </a></span>ucx_mempool_set_destr()</h2> | |
469 | ||
470 | <div class="memitem"> | |
471 | <div class="memproto"> | |
472 | <table class="memname"> | |
473 | <tr> | |
474 | <td class="memname">void ucx_mempool_set_destr </td> | |
475 | <td>(</td> | |
476 | <td class="paramtype">void * </td> | |
477 | <td class="paramname"><em>ptr</em>, </td> | |
478 | </tr> | |
479 | <tr> | |
480 | <td class="paramkey"></td> | |
481 | <td></td> | |
482 | <td class="paramtype"><a class="el" href="ucx_8h.html#ad2b370c2809914c8b7fedab163c266b3">ucx_destructor</a> </td> | |
483 | <td class="paramname"><em>func</em> </td> | |
484 | </tr> | |
485 | <tr> | |
486 | <td></td> | |
487 | <td>)</td> | |
488 | <td></td><td></td> | |
489 | </tr> | |
490 | </table> | |
491 | </div><div class="memdoc"> | |
492 | ||
493 | <p>Sets a destructor function for the specified memory. </p> | |
494 | <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> | |
495 | <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> | |
496 | <dl class="params"><dt>Parameters</dt><dd> | |
497 | <table class="params"> | |
498 | <tr><td class="paramname">ptr</td><td>pooled memory </td></tr> | |
499 | <tr><td class="paramname">func</td><td>a pointer to the destructor function </td></tr> | |
500 | </table> | |
501 | </dd> | |
502 | </dl> | |
503 | <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> | |
504 | <dd> | |
505 | <a class="el" href="mempool_8h.html#af096378da7e9bfbed3088497cf4c15bf" title="Destroys a memory pool. ">ucx_mempool_destroy()</a> </dd></dl> | |
506 | ||
507 | </div> | |
508 | </div> | |
509 | </div><!-- contents --> | |
510 | <!-- start footer part --> | |
511 | <hr class="footer"/><address class="footer"><small> | |
512 | Generated on Thu Dec 19 2019 19:58:24 for ucx by  <a href="http://www.doxygen.org/index.html"> | |
513 | <img class="footer" src="doxygen.png" alt="doxygen"/> | |
514 | </a> 1.8.13 | |
515 | </small></address> | |
516 | </body> | |
517 | </html> |