-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathalloc_8h.html
More file actions
340 lines (320 loc) · 23.8 KB
/
alloc_8h.html
File metadata and controls
340 lines (320 loc) · 23.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="generator" content="Doxygen 1.9.5"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>ah_base/include/ah/alloc.h File Reference - Eclipse Arrowhead™ Core C Libraries</title>
<script src="jquery.js"></script>
<script 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>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&dn=expat.txt MIT */
$(document).ready(function() { init_search(); });
/* @license-end */
</script>
<script>
window.addEventListener("load", () => {
let contents = document.querySelector("body > div.contents");
if (!contents) {
return;
}
document.querySelectorAll("#top ul > li.current > a > span").forEach((selectedMenuItem) => {
contents.classList.add(selectedMenuItem.innerText.trim().toLowerCase().replace(/\s+/, "-"));
});
for (let i = contents.childNodes.length - 1; i >= 0; i -= 1) {
let childNode = contents.childNodes.item(i);
if ((childNode.nodeType === 3 && childNode.textContent.trim().length === 0)
|| (childNode.nodeType === 1 && childNode.classList.contains("textblock") && childNode.textContent.trim().length === 0)) {
childNode.remove();
}
}
});
</script>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<link href="DoxygenStyle.css" rel="stylesheet" type="text/css"/>
</head>
<body>
<div id="top">
<header>
<img alt="Logo" src="arrowhead-logo-white.svg"/>
<h1>Eclipse Arrowhead™ Core C Libraries <span class="version"></span></h1>
</header>
<!-- Generated by Doxygen 1.9.5 -->
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&dn=expat.txt MIT */
var searchBox = new SearchBox("searchBox", "search/",'.html');
/* @license-end */
</script>
<div id="navrow1" class="tabs">
<ul class="tablist">
<li><a href="index.html"><span>Overview</span></a></li>
<li><a href="files.html"><span>Headers</span></a></li>
<li><a href="annotated.html"><span>Data Structures</span></a></li>
<li><a href="examples.html"><span>Examples</span></a></li>
<li>
<div id="MSearchBox" class="MSearchBoxInactive">
<span class="left">
<span id="MSearchSelect" onmouseover="return searchBox.OnSearchSelectShow()" onmouseout="return searchBox.OnSearchSelectHide()"> </span>
<input type="text" id="MSearchField" value="" placeholder="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.svg" alt=""/></a>
</span>
</div>
</li>
</ul>
</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">
<div id="MSearchResults">
<div class="SRPage">
<div id="SRIndex">
<div id="SRResults"></div>
<div class="SRStatus" id="Loading">Loading...</div>
<div class="SRStatus" id="Searching">Searching...</div>
<div class="SRStatus" id="NoMatches">No Matches</div>
</div>
</div>
</div>
</div>
<div id="nav-path" class="navpath">
<ul>
<li class="navelem"><a class="el" href="dir_e181be20417508ccbaf60a7ad88b28e5.html">ah_base</a></li><li class="navelem"><a class="el" href="dir_4e09807cd623eda32c4b1ef4b2b976fd.html">include</a></li><li class="navelem"><a class="el" href="dir_d9de5a19e148cb2028fab693738defa4.html">ah</a></li> </ul>
</div>
</div><!-- top -->
<div class="header">
<div class="summary">
<a href="#define-members">Macros</a> </div>
<div class="headertitle"><div class="title">alloc.h File Reference</div></div>
</div><!--header-->
<div class="contents">
<a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2>
<div class="textblock"><p >Dynamic memory allocation. </p>
<p >This file most significantly provides function for allocating and freeing dynamic memory. It provides two allocators, a <em>page allocator</em> and the <em>C99 allocator</em>. The implementations of the allocators can be changed by specifying their replacements as directed in <a class="el" href="conf_8h.html" title="Library configuration.">conf.h</a>.</p>
<h3>Page Allocator</h3>
<p >A <em>page</em> is a contiguous chunk of <a class="el" href="alloc_8h.html#acf3a4492f083f0f4868f515f16441070">AH_PSIZE</a> bytes, aligned to a memory boundary deemed suitable by the current library platform implementation. The page allocator provides and recycles such pages via the <a class="el" href="alloc_8h.html#a911d4e66ad39e4007ef01aec5a0ec06a" title="Allocates a page of memory, guaranteed to be at least AH_PSIZE bytes large.">ah_palloc()</a> and <a class="el" href="alloc_8h.html#a8d6cccf58f7975d91679bbfbdf702c6d" title="Releases referenced memory page, making it possible for the page allocator to use it again.">ah_pfree()</a> functions.</p>
<p >In contrast to the C99 allocator, the page allocator is relatively simple to implement. As every page is of the exact same size, the allocator may return any of them when new memory is requested. An implementation of a page allocator may, for example, use a predefined set of chunks and keep track of which of them are available for allocation via a single linked list.</p>
<p >The page allocator is used, when possible, by the Arrowhead Core C libraries.</p>
<h3>C99 Allocator</h3>
<p >The C99 allocator concretely consists of the <code>malloc()</code>, <code>calloc()</code>, <code>realloc()</code> and <code>free()</code> functions. However, implementing these in a manner that is both space-efficient and performant can be difficult, and especially so on embedded platforms. As a consequence, this library, and most other official Arrowhead C libraries, are designed to work even when the implementations of these functions are very limited. More specifically, an acceptable C99 allocator implementation </p><ol>
<li>
returns valid pointers when allocating new memory (if the requested number of bytes of heap memory are available), </li>
<li>
fails every attempt to reallocate memory (i.e. the first argument to <code>realloc()</code> is not <code>NULL</code>), and </li>
<li>
ignores any attempt to free memory. </li>
</ol>
<p>All library functionality that relies on being able to continually allocate and release memory must use the page allocator or be able to operate without using the C99 allocator at all.</p>
<dl class="section note"><dt>Note</dt><dd>Please refer to <a class="el" href="conf_8h.html" title="Library configuration.">conf.h</a> for more details on how to configure what C99 allocator function implementations are to be used. </dd></dl>
</div>
<p><a href="alloc_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 id="define-members" name="define-members"></a>
Macros</h2></td></tr>
<tr class="memitem:af60bc3ffcf5977b5603888f9c70cc74a"><td class="memItemLeft" align="right" valign="top">#define </td><td class="memItemRight" valign="bottom"><a class="el" href="alloc_8h.html#af60bc3ffcf5977b5603888f9c70cc74a">ah_calloc</a>(n, size)   <a class="el" href="conf_8h.html#a19996360d443048866c0046ebc5cdcc3">AH_CONF_CALLOC</a>((n), (size))</td></tr>
<tr class="memdesc:af60bc3ffcf5977b5603888f9c70cc74a"><td class="mdescLeft"> </td><td class="mdescRight">Allocates and zeroes an array of <em>n</em> elements, each being <em>size</em> bytes large. <a href="alloc_8h.html#af60bc3ffcf5977b5603888f9c70cc74a">More...</a><br /></td></tr>
<tr class="separator:af60bc3ffcf5977b5603888f9c70cc74a"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:a28b2cc0476e2976f7a3ca4e8f23a1938"><td class="memItemLeft" align="right" valign="top">#define </td><td class="memItemRight" valign="bottom"><a class="el" href="alloc_8h.html#a28b2cc0476e2976f7a3ca4e8f23a1938">ah_free</a>(ptr)   <a class="el" href="conf_8h.html#a3ad23dbb366fc5b79aa143d2e2618f58">AH_CONF_FREE</a>((ptr))</td></tr>
<tr class="memdesc:a28b2cc0476e2976f7a3ca4e8f23a1938"><td class="mdescLeft"> </td><td class="mdescRight">Releases referenced memory block, potentially making it possible for the allocator to use it again. <a href="alloc_8h.html#a28b2cc0476e2976f7a3ca4e8f23a1938">More...</a><br /></td></tr>
<tr class="separator:a28b2cc0476e2976f7a3ca4e8f23a1938"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:a026109a0711522c5144ecd324d1e64ff"><td class="memItemLeft" align="right" valign="top">#define </td><td class="memItemRight" valign="bottom"><a class="el" href="alloc_8h.html#a026109a0711522c5144ecd324d1e64ff">ah_malloc</a>(size)   <a class="el" href="conf_8h.html#ac2d062d4332ea48573da34ee776e85a9">AH_CONF_MALLOC</a>((size))</td></tr>
<tr class="memdesc:a026109a0711522c5144ecd324d1e64ff"><td class="mdescLeft"> </td><td class="mdescRight">Allocates a contiguous chunk of at least <em>size</em> bytes of memory. <a href="alloc_8h.html#a026109a0711522c5144ecd324d1e64ff">More...</a><br /></td></tr>
<tr class="separator:a026109a0711522c5144ecd324d1e64ff"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:a911d4e66ad39e4007ef01aec5a0ec06a"><td class="memItemLeft" align="right" valign="top">#define </td><td class="memItemRight" valign="bottom"><a class="el" href="alloc_8h.html#a911d4e66ad39e4007ef01aec5a0ec06a">ah_palloc</a>()   <a class="el" href="conf_8h.html#ae4da26828f60519b05deb87631ad4a3f">AH_CONF_PALLOC</a>()</td></tr>
<tr class="memdesc:a911d4e66ad39e4007ef01aec5a0ec06a"><td class="mdescLeft"> </td><td class="mdescRight">Allocates a <em>page</em> of memory, guaranteed to be at least <a class="el" href="alloc_8h.html#acf3a4492f083f0f4868f515f16441070">AH_PSIZE</a> bytes large. <a href="alloc_8h.html#a911d4e66ad39e4007ef01aec5a0ec06a">More...</a><br /></td></tr>
<tr class="separator:a911d4e66ad39e4007ef01aec5a0ec06a"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:a8d6cccf58f7975d91679bbfbdf702c6d"><td class="memItemLeft" align="right" valign="top">#define </td><td class="memItemRight" valign="bottom"><a class="el" href="alloc_8h.html#a8d6cccf58f7975d91679bbfbdf702c6d">ah_pfree</a>(page)   <a class="el" href="conf_8h.html#a99b32d7175d0b45a601f2b0063964ce2">AH_CONF_PFREE</a>((page))</td></tr>
<tr class="memdesc:a8d6cccf58f7975d91679bbfbdf702c6d"><td class="mdescLeft"> </td><td class="mdescRight">Releases referenced memory page, making it possible for the page allocator to use it again. <a href="alloc_8h.html#a8d6cccf58f7975d91679bbfbdf702c6d">More...</a><br /></td></tr>
<tr class="separator:a8d6cccf58f7975d91679bbfbdf702c6d"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:acf3a4492f083f0f4868f515f16441070"><td class="memItemLeft" align="right" valign="top"><a id="acf3a4492f083f0f4868f515f16441070" name="acf3a4492f083f0f4868f515f16441070"></a>
#define </td><td class="memItemRight" valign="bottom"><b>AH_PSIZE</b>   <a class="el" href="conf_8h.html#a635d29d236e1757dfedb399a64ef3576">AH_CONF_PSIZE</a></td></tr>
<tr class="memdesc:acf3a4492f083f0f4868f515f16441070"><td class="mdescLeft"> </td><td class="mdescRight">Size, in bytes, of the memory pages returned by <a class="el" href="alloc_8h.html#a911d4e66ad39e4007ef01aec5a0ec06a" title="Allocates a page of memory, guaranteed to be at least AH_PSIZE bytes large.">ah_palloc()</a>. <br /></td></tr>
<tr class="separator:acf3a4492f083f0f4868f515f16441070"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:a2648214e0896916bc9c91ff914b5adea"><td class="memItemLeft" align="right" valign="top">#define </td><td class="memItemRight" valign="bottom"><a class="el" href="alloc_8h.html#a2648214e0896916bc9c91ff914b5adea">ah_realloc</a>(ptr, size)   <a class="el" href="conf_8h.html#a6c8d793c98954aa8e1bf5894196f8c84">AH_CONF_REALLOC</a>((ptr), (size))</td></tr>
<tr class="memdesc:a2648214e0896916bc9c91ff914b5adea"><td class="mdescLeft"> </td><td class="mdescRight">Reallocates memory chunk associated with <em>ptr</em>. <a href="alloc_8h.html#a2648214e0896916bc9c91ff914b5adea">More...</a><br /></td></tr>
<tr class="separator:a2648214e0896916bc9c91ff914b5adea"><td class="memSeparator" colspan="2"> </td></tr>
</table>
<h2 class="groupheader">Macro Definition Documentation</h2>
<a id="af60bc3ffcf5977b5603888f9c70cc74a" name="af60bc3ffcf5977b5603888f9c70cc74a"></a>
<h2 class="memtitle"><span class="permalink"><a href="#af60bc3ffcf5977b5603888f9c70cc74a">◆ </a></span>ah_calloc</h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">#define ah_calloc</td>
<td>(</td>
<td class="paramtype"> </td>
<td class="paramname">n, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype"> </td>
<td class="paramname">size </td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td>   <a class="el" href="conf_8h.html#a19996360d443048866c0046ebc5cdcc3">AH_CONF_CALLOC</a>((n), (size))</td>
</tr>
</table>
</div><div class="memdoc">
<p>Allocates and zeroes an array of <em>n</em> elements, each being <em>size</em> bytes large. </p>
<p >If <em>n</em> multiplied by <em>size</em> overflows, this function must allocate no memory and return <code>NULL</code>.</p>
<dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramname">n</td><td>Number of elements to allocate. </td></tr>
<tr><td class="paramname">size</td><td>Size, in bytes, of each element. </td></tr>
</table>
</dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>A zeroed chunk of memory, or <code>NULL</code> if no sufficiently large chunk can be allocated. </dd></dl>
</div>
</div>
<a id="a28b2cc0476e2976f7a3ca4e8f23a1938" name="a28b2cc0476e2976f7a3ca4e8f23a1938"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a28b2cc0476e2976f7a3ca4e8f23a1938">◆ </a></span>ah_free</h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">#define ah_free</td>
<td>(</td>
<td class="paramtype"> </td>
<td class="paramname">ptr</td><td>)</td>
<td>   <a class="el" href="conf_8h.html#a3ad23dbb366fc5b79aa143d2e2618f58">AH_CONF_FREE</a>((ptr))</td>
</tr>
</table>
</div><div class="memdoc">
<p>Releases referenced memory block, potentially making it possible for the allocator to use it again. </p>
<dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramname">ptr</td><td>Pointer previously acquired from <a class="el" href="alloc_8h.html#af60bc3ffcf5977b5603888f9c70cc74a" title="Allocates and zeroes an array of n elements, each being size bytes large.">ah_calloc()</a>, <a class="el" href="alloc_8h.html#a026109a0711522c5144ecd324d1e64ff" title="Allocates a contiguous chunk of at least size bytes of memory.">ah_malloc()</a> or <a class="el" href="alloc_8h.html#a2648214e0896916bc9c91ff914b5adea" title="Reallocates memory chunk associated with ptr.">ah_realloc()</a>.</td></tr>
</table>
</dd>
</dl>
<dl class="section warning"><dt>Warning</dt><dd>It is an error to provide a pointer returned by <a class="el" href="alloc_8h.html#a911d4e66ad39e4007ef01aec5a0ec06a" title="Allocates a page of memory, guaranteed to be at least AH_PSIZE bytes large.">ah_palloc()</a>, or any other allocation function than those listed above, to this function. </dd></dl>
</div>
</div>
<a id="a026109a0711522c5144ecd324d1e64ff" name="a026109a0711522c5144ecd324d1e64ff"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a026109a0711522c5144ecd324d1e64ff">◆ </a></span>ah_malloc</h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">#define ah_malloc</td>
<td>(</td>
<td class="paramtype"> </td>
<td class="paramname">size</td><td>)</td>
<td>   <a class="el" href="conf_8h.html#ac2d062d4332ea48573da34ee776e85a9">AH_CONF_MALLOC</a>((size))</td>
</tr>
</table>
</div><div class="memdoc">
<p>Allocates a contiguous chunk of at least <em>size</em> bytes of memory. </p>
<dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramname">size</td><td>Size, in bytes, of chunk to allocate. </td></tr>
</table>
</dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>An uninitialized chunk of memory, or <code>NULL</code> if no sufficiently large chunk can be allocated. </dd></dl>
</div>
</div>
<a id="a911d4e66ad39e4007ef01aec5a0ec06a" name="a911d4e66ad39e4007ef01aec5a0ec06a"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a911d4e66ad39e4007ef01aec5a0ec06a">◆ </a></span>ah_palloc</h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">#define ah_palloc</td>
<td>(</td>
<td class="paramname"></td><td>)</td>
<td>   <a class="el" href="conf_8h.html#ae4da26828f60519b05deb87631ad4a3f">AH_CONF_PALLOC</a>()</td>
</tr>
</table>
</div><div class="memdoc">
<p>Allocates a <em>page</em> of memory, guaranteed to be at least <a class="el" href="alloc_8h.html#acf3a4492f083f0f4868f515f16441070">AH_PSIZE</a> bytes large. </p>
<p >The value of <a class="el" href="alloc_8h.html#acf3a4492f083f0f4868f515f16441070">AH_PSIZE</a> can be adjusted by modifying <code>AH_CONF_PSIZE</code>, more of which you can read in <a class="el" href="conf_8h.html" title="Library configuration.">conf.h</a>.</p>
<dl class="section return"><dt>Returns</dt><dd>An uninitialized chunk of memory, or <code>NULL</code> if no sufficiently large chunk can be allocated. </dd></dl>
</div>
</div>
<a id="a8d6cccf58f7975d91679bbfbdf702c6d" name="a8d6cccf58f7975d91679bbfbdf702c6d"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a8d6cccf58f7975d91679bbfbdf702c6d">◆ </a></span>ah_pfree</h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">#define ah_pfree</td>
<td>(</td>
<td class="paramtype"> </td>
<td class="paramname">page</td><td>)</td>
<td>   <a class="el" href="conf_8h.html#a99b32d7175d0b45a601f2b0063964ce2">AH_CONF_PFREE</a>((page))</td>
</tr>
</table>
</div><div class="memdoc">
<p>Releases referenced memory page, making it possible for the page allocator to use it again. </p>
<dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramname">page</td><td>Pointer previously acquired from <a class="el" href="alloc_8h.html#a911d4e66ad39e4007ef01aec5a0ec06a" title="Allocates a page of memory, guaranteed to be at least AH_PSIZE bytes large.">ah_palloc()</a>.</td></tr>
</table>
</dd>
</dl>
<dl class="section warning"><dt>Warning</dt><dd>It is an error to provide a pointer returned by <a class="el" href="alloc_8h.html#af60bc3ffcf5977b5603888f9c70cc74a" title="Allocates and zeroes an array of n elements, each being size bytes large.">ah_calloc()</a>, <a class="el" href="alloc_8h.html#a026109a0711522c5144ecd324d1e64ff" title="Allocates a contiguous chunk of at least size bytes of memory.">ah_malloc()</a> or any other allocation function than <a class="el" href="alloc_8h.html#a911d4e66ad39e4007ef01aec5a0ec06a" title="Allocates a page of memory, guaranteed to be at least AH_PSIZE bytes large.">ah_palloc()</a>, to this function. </dd></dl>
</div>
</div>
<a id="a2648214e0896916bc9c91ff914b5adea" name="a2648214e0896916bc9c91ff914b5adea"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a2648214e0896916bc9c91ff914b5adea">◆ </a></span>ah_realloc</h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">#define ah_realloc</td>
<td>(</td>
<td class="paramtype"> </td>
<td class="paramname">ptr, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype"> </td>
<td class="paramname">size </td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td>   <a class="el" href="conf_8h.html#a6c8d793c98954aa8e1bf5894196f8c84">AH_CONF_REALLOC</a>((ptr), (size))</td>
</tr>
</table>
</div><div class="memdoc">
<p>Reallocates memory chunk associated with <em>ptr</em>. </p>
<p >Conceptually, this function allocates a new memory chunk of <em>size</em> bytes, copies over the contents of the <em>ptr</em> buffer (or as much of it as fits in the new chunk), and then frees the memory associated with <em>ptr</em>. If <em>size</em> is larger than the previous size of the <em>ptr</em> chunk, the additional memory is uninitialized. Practically, this function may expand or contract the <em>ptr</em> chunk in place, or do something else with the same observable result.</p>
<dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramname">ptr</td><td>Pointer previously acquired from <a class="el" href="alloc_8h.html#af60bc3ffcf5977b5603888f9c70cc74a" title="Allocates and zeroes an array of n elements, each being size bytes large.">ah_calloc()</a>, <a class="el" href="alloc_8h.html#a026109a0711522c5144ecd324d1e64ff" title="Allocates a contiguous chunk of at least size bytes of memory.">ah_malloc()</a> or <a class="el" href="alloc_8h.html#a2648214e0896916bc9c91ff914b5adea" title="Reallocates memory chunk associated with ptr.">ah_realloc()</a>. </td></tr>
<tr><td class="paramname">size</td><td>Desired size, in bytes, of chunk after reallocation. </td></tr>
</table>
</dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>A chunk of memory of at least <em>size</em> bytes that contain the contents previously associated with <em>ptr</em>. <code>NULL</code> if the reallocation failed, in which case the chunk of <em>ptr</em> remains unmodified.</dd></dl>
<dl class="section note"><dt>Note</dt><dd>If <em>size</em> <em>is not</em> <code>0</code> and <em>ptr</em> <em>is</em> <code>NULL</code>, this function will behave exactly as a call to <a class="el" href="alloc_8h.html#a026109a0711522c5144ecd324d1e64ff" title="Allocates a contiguous chunk of at least size bytes of memory.">ah_malloc()</a> with the same size.</dd></dl>
<dl class="section warning"><dt>Warning</dt><dd>If <em>size</em> <em>is not</em> <code>0</code> and <em>ptr</em> <em>is not</em> <code>NULL</code>, this function may, if implemented so, always return <code>NULL</code>.</dd>
<dd>
If <em>size</em> <em>is</em> <code>0</code> and <em>ptr</em> <em>is not</em> <code>NULL</code>, the function may either return a pointer to a memory chunk with size <code>0</code> or return <code>NULL</code>.</dd>
<dd>
If <em>size</em> <em>is</em> <code>0</code> and <em>ptr</em> <em>is</em> <code>NULL</code>, the result of calling this function is undefined. </dd></dl>
</div>
</div>
</div><!-- contents -->
<footer>Generated by <a href="https://doxygen.org">Doxygen</a> 1.9.5</footer>
</body>
</html>