579 lines
33 KiB
HTML
579 lines
33 KiB
HTML
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
|
<html xmlns="http://www.w3.org/1999/xhtml" lang="en-US">
|
|
<head>
|
|
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
|
|
<meta http-equiv="X-UA-Compatible" content="IE=11"/>
|
|
<meta name="generator" content="Doxygen 1.11.0"/>
|
|
<meta name="viewport" content="width=device-width, initial-scale=1"/>
|
|
<title>mi-malloc: Basic Allocation</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>
|
|
<script type="text/javascript" src="clipboard.js"></script>
|
|
<link href="navtree.css" rel="stylesheet" type="text/css"/>
|
|
<script type="text/javascript" src="navtreedata.js"></script>
|
|
<script type="text/javascript" src="navtree.js"></script>
|
|
<script type="text/javascript" src="resize.js"></script>
|
|
<script type="text/javascript" src="cookie.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 */
|
|
$(function() { init_search(); });
|
|
/* @license-end */
|
|
</script>
|
|
<link href="doxygen.css" rel="stylesheet" type="text/css" />
|
|
<link href="mimalloc-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 id="projectrow">
|
|
<td id="projectlogo"><img alt="Logo" src="mimalloc-logo.svg"/></td>
|
|
<td id="projectalign">
|
|
<div id="projectname">mi-malloc<span id="projectnumber"> 1.8/2.1</span>
|
|
</div>
|
|
</td>
|
|
<td> <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>
|
|
</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
<!-- end header part -->
|
|
<!-- Generated by Doxygen 1.11.0 -->
|
|
<script type="text/javascript">
|
|
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&dn=expat.txt MIT */
|
|
var searchBox = new SearchBox("searchBox", "search/",'.html');
|
|
/* @license-end */
|
|
</script>
|
|
<script type="text/javascript">
|
|
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&dn=expat.txt MIT */
|
|
$(function() { codefold.init(0); });
|
|
/* @license-end */
|
|
</script>
|
|
</div><!-- top -->
|
|
<div id="side-nav" class="ui-resizable side-nav-resizable">
|
|
<div id="nav-tree">
|
|
<div id="nav-tree-contents">
|
|
<div id="nav-sync" class="sync"></div>
|
|
</div>
|
|
</div>
|
|
<div id="splitbar" style="-moz-user-select:none;"
|
|
class="ui-resizable-handle">
|
|
</div>
|
|
</div>
|
|
<script type="text/javascript">
|
|
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&dn=expat.txt MIT */
|
|
$(function(){initNavTree('group__malloc.html',''); initResizable(true); });
|
|
/* @license-end */
|
|
</script>
|
|
<div id="doc-content">
|
|
<!-- 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 class="header">
|
|
<div class="summary">
|
|
<a href="#func-members">Functions</a> </div>
|
|
<div class="headertitle"><div class="title">Basic Allocation</div></div>
|
|
</div><!--header-->
|
|
<div class="contents">
|
|
|
|
<p>The basic allocation interface.
|
|
<a href="#details">More...</a></p>
|
|
<table class="memberdecls">
|
|
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a id="func-members" name="func-members"></a>
|
|
Functions</h2></td></tr>
|
|
<tr class="memitem:gaf2c7b89c327d1f60f59e68b9ea644d95" id="r_gaf2c7b89c327d1f60f59e68b9ea644d95"><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="#gaf2c7b89c327d1f60f59e68b9ea644d95">mi_free</a> (void *p)</td></tr>
|
|
<tr class="memdesc:gaf2c7b89c327d1f60f59e68b9ea644d95"><td class="mdescLeft"> </td><td class="mdescRight">Free previously allocated memory. <br /></td></tr>
|
|
<tr class="separator:gaf2c7b89c327d1f60f59e68b9ea644d95"><td class="memSeparator" colspan="2"> </td></tr>
|
|
<tr class="memitem:gae1dd97b542420c87ae085e822b1229e8" id="r_gae1dd97b542420c87ae085e822b1229e8"><td class="memItemLeft" align="right" valign="top">void * </td><td class="memItemRight" valign="bottom"><a class="el" href="#gae1dd97b542420c87ae085e822b1229e8">mi_malloc</a> (size_t size)</td></tr>
|
|
<tr class="memdesc:gae1dd97b542420c87ae085e822b1229e8"><td class="mdescLeft"> </td><td class="mdescRight">Allocate <em>size</em> bytes. <br /></td></tr>
|
|
<tr class="separator:gae1dd97b542420c87ae085e822b1229e8"><td class="memSeparator" colspan="2"> </td></tr>
|
|
<tr class="memitem:gae6e38c4403247a7b40d80419e093bfb8" id="r_gae6e38c4403247a7b40d80419e093bfb8"><td class="memItemLeft" align="right" valign="top">void * </td><td class="memItemRight" valign="bottom"><a class="el" href="#gae6e38c4403247a7b40d80419e093bfb8">mi_zalloc</a> (size_t size)</td></tr>
|
|
<tr class="memdesc:gae6e38c4403247a7b40d80419e093bfb8"><td class="mdescLeft"> </td><td class="mdescRight">Allocate zero-initialized <code>size</code> bytes. <br /></td></tr>
|
|
<tr class="separator:gae6e38c4403247a7b40d80419e093bfb8"><td class="memSeparator" colspan="2"> </td></tr>
|
|
<tr class="memitem:ga6686568014b54d1e6c7ac64a076e4f56" id="r_ga6686568014b54d1e6c7ac64a076e4f56"><td class="memItemLeft" align="right" valign="top">void * </td><td class="memItemRight" valign="bottom"><a class="el" href="#ga6686568014b54d1e6c7ac64a076e4f56">mi_calloc</a> (size_t count, size_t size)</td></tr>
|
|
<tr class="memdesc:ga6686568014b54d1e6c7ac64a076e4f56"><td class="mdescLeft"> </td><td class="mdescRight">Allocate zero-initialized <em>count</em> elements of <em>size</em> bytes. <br /></td></tr>
|
|
<tr class="separator:ga6686568014b54d1e6c7ac64a076e4f56"><td class="memSeparator" colspan="2"> </td></tr>
|
|
<tr class="memitem:ga0621af6a5e3aa384e6a1b548958bf583" id="r_ga0621af6a5e3aa384e6a1b548958bf583"><td class="memItemLeft" align="right" valign="top">void * </td><td class="memItemRight" valign="bottom"><a class="el" href="#ga0621af6a5e3aa384e6a1b548958bf583">mi_realloc</a> (void *p, size_t newsize)</td></tr>
|
|
<tr class="memdesc:ga0621af6a5e3aa384e6a1b548958bf583"><td class="mdescLeft"> </td><td class="mdescRight">Re-allocate memory to <em>newsize</em> bytes. <br /></td></tr>
|
|
<tr class="separator:ga0621af6a5e3aa384e6a1b548958bf583"><td class="memSeparator" colspan="2"> </td></tr>
|
|
<tr class="memitem:ga23a0fbb452b5dce8e31fab1a1958cacc" id="r_ga23a0fbb452b5dce8e31fab1a1958cacc"><td class="memItemLeft" align="right" valign="top">void * </td><td class="memItemRight" valign="bottom"><a class="el" href="#ga23a0fbb452b5dce8e31fab1a1958cacc">mi_recalloc</a> (void *p, size_t count, size_t size)</td></tr>
|
|
<tr class="memdesc:ga23a0fbb452b5dce8e31fab1a1958cacc"><td class="mdescLeft"> </td><td class="mdescRight">Re-allocate memory to <em>count</em> elements of <em>size</em> bytes, with extra memory initialized to zero. <br /></td></tr>
|
|
<tr class="separator:ga23a0fbb452b5dce8e31fab1a1958cacc"><td class="memSeparator" colspan="2"> </td></tr>
|
|
<tr class="memitem:ga19299856216cfbb08e2628593654dfb0" id="r_ga19299856216cfbb08e2628593654dfb0"><td class="memItemLeft" align="right" valign="top">void * </td><td class="memItemRight" valign="bottom"><a class="el" href="#ga19299856216cfbb08e2628593654dfb0">mi_expand</a> (void *p, size_t newsize)</td></tr>
|
|
<tr class="memdesc:ga19299856216cfbb08e2628593654dfb0"><td class="mdescLeft"> </td><td class="mdescRight">Try to re-allocate memory to <em>newsize</em> bytes <em>in place</em>. <br /></td></tr>
|
|
<tr class="separator:ga19299856216cfbb08e2628593654dfb0"><td class="memSeparator" colspan="2"> </td></tr>
|
|
<tr class="memitem:ga61f46bade3db76ca24aaafedc40de7b6" id="r_ga61f46bade3db76ca24aaafedc40de7b6"><td class="memItemLeft" align="right" valign="top">void * </td><td class="memItemRight" valign="bottom"><a class="el" href="#ga61f46bade3db76ca24aaafedc40de7b6">mi_mallocn</a> (size_t count, size_t size)</td></tr>
|
|
<tr class="memdesc:ga61f46bade3db76ca24aaafedc40de7b6"><td class="mdescLeft"> </td><td class="mdescRight">Allocate <em>count</em> elements of <em>size</em> bytes. <br /></td></tr>
|
|
<tr class="separator:ga61f46bade3db76ca24aaafedc40de7b6"><td class="memSeparator" colspan="2"> </td></tr>
|
|
<tr class="memitem:ga8bddfb4a1270a0854bbcf44cb3980467" id="r_ga8bddfb4a1270a0854bbcf44cb3980467"><td class="memItemLeft" align="right" valign="top">void * </td><td class="memItemRight" valign="bottom"><a class="el" href="#ga8bddfb4a1270a0854bbcf44cb3980467">mi_reallocn</a> (void *p, size_t count, size_t size)</td></tr>
|
|
<tr class="memdesc:ga8bddfb4a1270a0854bbcf44cb3980467"><td class="mdescLeft"> </td><td class="mdescRight">Re-allocate memory to <em>count</em> elements of <em>size</em> bytes. <br /></td></tr>
|
|
<tr class="separator:ga8bddfb4a1270a0854bbcf44cb3980467"><td class="memSeparator" colspan="2"> </td></tr>
|
|
<tr class="memitem:ga4dc3a4067037b151a64629fe8a332641" id="r_ga4dc3a4067037b151a64629fe8a332641"><td class="memItemLeft" align="right" valign="top">void * </td><td class="memItemRight" valign="bottom"><a class="el" href="#ga4dc3a4067037b151a64629fe8a332641">mi_reallocf</a> (void *p, size_t newsize)</td></tr>
|
|
<tr class="memdesc:ga4dc3a4067037b151a64629fe8a332641"><td class="mdescLeft"> </td><td class="mdescRight">Re-allocate memory to <em>newsize</em> bytes,. <br /></td></tr>
|
|
<tr class="separator:ga4dc3a4067037b151a64629fe8a332641"><td class="memSeparator" colspan="2"> </td></tr>
|
|
<tr class="memitem:ga245ac90ebc2cfdd17de599e5fea59889" id="r_ga245ac90ebc2cfdd17de599e5fea59889"><td class="memItemLeft" align="right" valign="top">char * </td><td class="memItemRight" valign="bottom"><a class="el" href="#ga245ac90ebc2cfdd17de599e5fea59889">mi_strdup</a> (const char *s)</td></tr>
|
|
<tr class="memdesc:ga245ac90ebc2cfdd17de599e5fea59889"><td class="mdescLeft"> </td><td class="mdescRight">Allocate and duplicate a string. <br /></td></tr>
|
|
<tr class="separator:ga245ac90ebc2cfdd17de599e5fea59889"><td class="memSeparator" colspan="2"> </td></tr>
|
|
<tr class="memitem:ga486d0d26b3b3794f6d1cdb41a9aed92d" id="r_ga486d0d26b3b3794f6d1cdb41a9aed92d"><td class="memItemLeft" align="right" valign="top">char * </td><td class="memItemRight" valign="bottom"><a class="el" href="#ga486d0d26b3b3794f6d1cdb41a9aed92d">mi_strndup</a> (const char *s, size_t n)</td></tr>
|
|
<tr class="memdesc:ga486d0d26b3b3794f6d1cdb41a9aed92d"><td class="mdescLeft"> </td><td class="mdescRight">Allocate and duplicate a string up to <em>n</em> bytes. <br /></td></tr>
|
|
<tr class="separator:ga486d0d26b3b3794f6d1cdb41a9aed92d"><td class="memSeparator" colspan="2"> </td></tr>
|
|
<tr class="memitem:ga94c3afcc086e85d75a57e9f76b9b71dd" id="r_ga94c3afcc086e85d75a57e9f76b9b71dd"><td class="memItemLeft" align="right" valign="top">char * </td><td class="memItemRight" valign="bottom"><a class="el" href="#ga94c3afcc086e85d75a57e9f76b9b71dd">mi_realpath</a> (const char *fname, char *resolved_name)</td></tr>
|
|
<tr class="memdesc:ga94c3afcc086e85d75a57e9f76b9b71dd"><td class="mdescLeft"> </td><td class="mdescRight">Resolve a file path name. <br /></td></tr>
|
|
<tr class="separator:ga94c3afcc086e85d75a57e9f76b9b71dd"><td class="memSeparator" colspan="2"> </td></tr>
|
|
</table>
|
|
<a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2>
|
|
<p>The basic allocation interface. </p>
|
|
<h2 class="groupheader">Function Documentation</h2>
|
|
<a id="ga6686568014b54d1e6c7ac64a076e4f56" name="ga6686568014b54d1e6c7ac64a076e4f56"></a>
|
|
<h2 class="memtitle"><span class="permalink"><a href="#ga6686568014b54d1e6c7ac64a076e4f56">◆ </a></span>mi_calloc()</h2>
|
|
|
|
<div class="memitem">
|
|
<div class="memproto">
|
|
<table class="memname">
|
|
<tr>
|
|
<td class="memname">void * mi_calloc </td>
|
|
<td>(</td>
|
|
<td class="paramtype">size_t</td> <td class="paramname"><span class="paramname"><em>count</em></span>, </td>
|
|
</tr>
|
|
<tr>
|
|
<td class="paramkey"></td>
|
|
<td></td>
|
|
<td class="paramtype">size_t</td> <td class="paramname"><span class="paramname"><em>size</em></span> )</td>
|
|
</tr>
|
|
</table>
|
|
</div><div class="memdoc">
|
|
|
|
<p>Allocate zero-initialized <em>count</em> elements of <em>size</em> bytes. </p>
|
|
<dl class="params"><dt>Parameters</dt><dd>
|
|
<table class="params">
|
|
<tr><td class="paramname">count</td><td>number of elements. </td></tr>
|
|
<tr><td class="paramname">size</td><td>size of each element. </td></tr>
|
|
</table>
|
|
</dd>
|
|
</dl>
|
|
<dl class="section return"><dt>Returns</dt><dd>pointer to the allocated memory of <em>size*<em>count</em> bytes</em>, or <em>NULL</em> if either out of memory or when <code>count*size</code> overflows.</dd></dl>
|
|
<p>Returns a unique pointer if called with either <em>size</em> or <em>count</em> of 0. </p><dl class="section see"><dt>See also</dt><dd><a class="el" href="#gae6e38c4403247a7b40d80419e093bfb8" title="Allocate zero-initialized size bytes.">mi_zalloc()</a> </dd></dl>
|
|
|
|
</div>
|
|
</div>
|
|
<a id="ga19299856216cfbb08e2628593654dfb0" name="ga19299856216cfbb08e2628593654dfb0"></a>
|
|
<h2 class="memtitle"><span class="permalink"><a href="#ga19299856216cfbb08e2628593654dfb0">◆ </a></span>mi_expand()</h2>
|
|
|
|
<div class="memitem">
|
|
<div class="memproto">
|
|
<table class="memname">
|
|
<tr>
|
|
<td class="memname">void * mi_expand </td>
|
|
<td>(</td>
|
|
<td class="paramtype">void *</td> <td class="paramname"><span class="paramname"><em>p</em></span>, </td>
|
|
</tr>
|
|
<tr>
|
|
<td class="paramkey"></td>
|
|
<td></td>
|
|
<td class="paramtype">size_t</td> <td class="paramname"><span class="paramname"><em>newsize</em></span> )</td>
|
|
</tr>
|
|
</table>
|
|
</div><div class="memdoc">
|
|
|
|
<p>Try to re-allocate memory to <em>newsize</em> bytes <em>in place</em>. </p>
|
|
<dl class="params"><dt>Parameters</dt><dd>
|
|
<table class="params">
|
|
<tr><td class="paramname">p</td><td>pointer to previously allocated memory (or <em>NULL</em>). </td></tr>
|
|
<tr><td class="paramname">newsize</td><td>the new required size in bytes. </td></tr>
|
|
</table>
|
|
</dd>
|
|
</dl>
|
|
<dl class="section return"><dt>Returns</dt><dd>pointer to the re-allocated memory of <em>newsize</em> bytes (always equal to <em>p</em>), or <em>NULL</em> if either out of memory or if the memory could not be expanded in place. If <em>NULL</em> is returned, the pointer <em>p</em> is not freed. Otherwise the original pointer is returned as the reallocated result since it fits in-place with the new size. If <em>newsize</em> is larger than the original <em>size</em> allocated for <em>p</em>, the bytes after <em>size</em> are uninitialized. </dd></dl>
|
|
|
|
</div>
|
|
</div>
|
|
<a id="gaf2c7b89c327d1f60f59e68b9ea644d95" name="gaf2c7b89c327d1f60f59e68b9ea644d95"></a>
|
|
<h2 class="memtitle"><span class="permalink"><a href="#gaf2c7b89c327d1f60f59e68b9ea644d95">◆ </a></span>mi_free()</h2>
|
|
|
|
<div class="memitem">
|
|
<div class="memproto">
|
|
<table class="memname">
|
|
<tr>
|
|
<td class="memname">void mi_free </td>
|
|
<td>(</td>
|
|
<td class="paramtype">void *</td> <td class="paramname"><span class="paramname"><em>p</em></span></td><td>)</td>
|
|
<td></td>
|
|
</tr>
|
|
</table>
|
|
</div><div class="memdoc">
|
|
|
|
<p>Free previously allocated memory. </p>
|
|
<p>The pointer <code>p</code> must have been allocated before (or be <em>NULL</em>). </p><dl class="params"><dt>Parameters</dt><dd>
|
|
<table class="params">
|
|
<tr><td class="paramname">p</td><td>pointer to free, or <em>NULL</em>. </td></tr>
|
|
</table>
|
|
</dd>
|
|
</dl>
|
|
|
|
</div>
|
|
</div>
|
|
<a id="gae1dd97b542420c87ae085e822b1229e8" name="gae1dd97b542420c87ae085e822b1229e8"></a>
|
|
<h2 class="memtitle"><span class="permalink"><a href="#gae1dd97b542420c87ae085e822b1229e8">◆ </a></span>mi_malloc()</h2>
|
|
|
|
<div class="memitem">
|
|
<div class="memproto">
|
|
<table class="memname">
|
|
<tr>
|
|
<td class="memname">void * mi_malloc </td>
|
|
<td>(</td>
|
|
<td class="paramtype">size_t</td> <td class="paramname"><span class="paramname"><em>size</em></span></td><td>)</td>
|
|
<td></td>
|
|
</tr>
|
|
</table>
|
|
</div><div class="memdoc">
|
|
|
|
<p>Allocate <em>size</em> bytes. </p>
|
|
<dl class="params"><dt>Parameters</dt><dd>
|
|
<table class="params">
|
|
<tr><td class="paramname">size</td><td>number of bytes to allocate. </td></tr>
|
|
</table>
|
|
</dd>
|
|
</dl>
|
|
<dl class="section return"><dt>Returns</dt><dd>pointer to the allocated memory or <em>NULL</em> if out of memory. Returns a unique pointer if called with <em>size</em> 0. </dd></dl>
|
|
|
|
</div>
|
|
</div>
|
|
<a id="ga61f46bade3db76ca24aaafedc40de7b6" name="ga61f46bade3db76ca24aaafedc40de7b6"></a>
|
|
<h2 class="memtitle"><span class="permalink"><a href="#ga61f46bade3db76ca24aaafedc40de7b6">◆ </a></span>mi_mallocn()</h2>
|
|
|
|
<div class="memitem">
|
|
<div class="memproto">
|
|
<table class="memname">
|
|
<tr>
|
|
<td class="memname">void * mi_mallocn </td>
|
|
<td>(</td>
|
|
<td class="paramtype">size_t</td> <td class="paramname"><span class="paramname"><em>count</em></span>, </td>
|
|
</tr>
|
|
<tr>
|
|
<td class="paramkey"></td>
|
|
<td></td>
|
|
<td class="paramtype">size_t</td> <td class="paramname"><span class="paramname"><em>size</em></span> )</td>
|
|
</tr>
|
|
</table>
|
|
</div><div class="memdoc">
|
|
|
|
<p>Allocate <em>count</em> elements of <em>size</em> bytes. </p>
|
|
<dl class="params"><dt>Parameters</dt><dd>
|
|
<table class="params">
|
|
<tr><td class="paramname">count</td><td>The number of elements. </td></tr>
|
|
<tr><td class="paramname">size</td><td>The size of each element. </td></tr>
|
|
</table>
|
|
</dd>
|
|
</dl>
|
|
<dl class="section return"><dt>Returns</dt><dd>A pointer to a block of <em>count</em> * <em>size</em> bytes, or <em>NULL</em> if out of memory or if <em>count</em> * <em>size</em> overflows.</dd></dl>
|
|
<p>If there is no overflow, it behaves exactly like <code>mi_malloc(count*size)</code>. </p><dl class="section see"><dt>See also</dt><dd><a class="el" href="#ga6686568014b54d1e6c7ac64a076e4f56" title="Allocate zero-initialized count elements of size bytes.">mi_calloc()</a> </dd>
|
|
<dd>
|
|
mi_zallocn() </dd></dl>
|
|
|
|
</div>
|
|
</div>
|
|
<a id="ga0621af6a5e3aa384e6a1b548958bf583" name="ga0621af6a5e3aa384e6a1b548958bf583"></a>
|
|
<h2 class="memtitle"><span class="permalink"><a href="#ga0621af6a5e3aa384e6a1b548958bf583">◆ </a></span>mi_realloc()</h2>
|
|
|
|
<div class="memitem">
|
|
<div class="memproto">
|
|
<table class="memname">
|
|
<tr>
|
|
<td class="memname">void * mi_realloc </td>
|
|
<td>(</td>
|
|
<td class="paramtype">void *</td> <td class="paramname"><span class="paramname"><em>p</em></span>, </td>
|
|
</tr>
|
|
<tr>
|
|
<td class="paramkey"></td>
|
|
<td></td>
|
|
<td class="paramtype">size_t</td> <td class="paramname"><span class="paramname"><em>newsize</em></span> )</td>
|
|
</tr>
|
|
</table>
|
|
</div><div class="memdoc">
|
|
|
|
<p>Re-allocate memory to <em>newsize</em> bytes. </p>
|
|
<dl class="params"><dt>Parameters</dt><dd>
|
|
<table class="params">
|
|
<tr><td class="paramname">p</td><td>pointer to previously allocated memory (or <em>NULL</em>). </td></tr>
|
|
<tr><td class="paramname">newsize</td><td>the new required size in bytes. </td></tr>
|
|
</table>
|
|
</dd>
|
|
</dl>
|
|
<dl class="section return"><dt>Returns</dt><dd>pointer to the re-allocated memory of <em>newsize</em> bytes, or <em>NULL</em> if out of memory. If <em>NULL</em> is returned, the pointer <em>p</em> is not freed. Otherwise the original pointer is either freed or returned as the reallocated result (in case it fits in-place with the new size). If the pointer <em>p</em> is <em>NULL</em>, it behaves as <em>mi_malloc</em>(<em>newsize</em>). If <em>newsize</em> is larger than the original <em>size</em> allocated for <em>p</em>, the bytes after <em>size</em> are uninitialized. </dd></dl>
|
|
|
|
</div>
|
|
</div>
|
|
<a id="ga4dc3a4067037b151a64629fe8a332641" name="ga4dc3a4067037b151a64629fe8a332641"></a>
|
|
<h2 class="memtitle"><span class="permalink"><a href="#ga4dc3a4067037b151a64629fe8a332641">◆ </a></span>mi_reallocf()</h2>
|
|
|
|
<div class="memitem">
|
|
<div class="memproto">
|
|
<table class="memname">
|
|
<tr>
|
|
<td class="memname">void * mi_reallocf </td>
|
|
<td>(</td>
|
|
<td class="paramtype">void *</td> <td class="paramname"><span class="paramname"><em>p</em></span>, </td>
|
|
</tr>
|
|
<tr>
|
|
<td class="paramkey"></td>
|
|
<td></td>
|
|
<td class="paramtype">size_t</td> <td class="paramname"><span class="paramname"><em>newsize</em></span> )</td>
|
|
</tr>
|
|
</table>
|
|
</div><div class="memdoc">
|
|
|
|
<p>Re-allocate memory to <em>newsize</em> bytes,. </p>
|
|
<dl class="params"><dt>Parameters</dt><dd>
|
|
<table class="params">
|
|
<tr><td class="paramname">p</td><td>pointer to previously allocated memory (or <em>NULL</em>). </td></tr>
|
|
<tr><td class="paramname">newsize</td><td>the new required size in bytes. </td></tr>
|
|
</table>
|
|
</dd>
|
|
</dl>
|
|
<dl class="section return"><dt>Returns</dt><dd>pointer to the re-allocated memory of <em>newsize</em> bytes, or <em>NULL</em> if out of memory.</dd></dl>
|
|
<p>In contrast to <a class="el" href="#ga0621af6a5e3aa384e6a1b548958bf583" title="Re-allocate memory to newsize bytes.">mi_realloc()</a>, if <em>NULL</em> is returned, the original pointer <em>p</em> is freed (if it was not <em>NULL</em> itself). Otherwise the original pointer is either freed or returned as the reallocated result (in case it fits in-place with the new size). If the pointer <em>p</em> is <em>NULL</em>, it behaves as <em>mi_malloc</em>(<em>newsize</em>). If <em>newsize</em> is larger than the original <em>size</em> allocated for <em>p</em>, the bytes after <em>size</em> are uninitialized.</p>
|
|
<dl class="section see"><dt>See also</dt><dd><a href="https://www.freebsd.org/cgi/man.cgi?query=reallocf">reallocf</a> (on BSD) </dd></dl>
|
|
|
|
</div>
|
|
</div>
|
|
<a id="ga8bddfb4a1270a0854bbcf44cb3980467" name="ga8bddfb4a1270a0854bbcf44cb3980467"></a>
|
|
<h2 class="memtitle"><span class="permalink"><a href="#ga8bddfb4a1270a0854bbcf44cb3980467">◆ </a></span>mi_reallocn()</h2>
|
|
|
|
<div class="memitem">
|
|
<div class="memproto">
|
|
<table class="memname">
|
|
<tr>
|
|
<td class="memname">void * mi_reallocn </td>
|
|
<td>(</td>
|
|
<td class="paramtype">void *</td> <td class="paramname"><span class="paramname"><em>p</em></span>, </td>
|
|
</tr>
|
|
<tr>
|
|
<td class="paramkey"></td>
|
|
<td></td>
|
|
<td class="paramtype">size_t</td> <td class="paramname"><span class="paramname"><em>count</em></span>, </td>
|
|
</tr>
|
|
<tr>
|
|
<td class="paramkey"></td>
|
|
<td></td>
|
|
<td class="paramtype">size_t</td> <td class="paramname"><span class="paramname"><em>size</em></span> )</td>
|
|
</tr>
|
|
</table>
|
|
</div><div class="memdoc">
|
|
|
|
<p>Re-allocate memory to <em>count</em> elements of <em>size</em> bytes. </p>
|
|
<dl class="params"><dt>Parameters</dt><dd>
|
|
<table class="params">
|
|
<tr><td class="paramname">p</td><td>Pointer to a previously allocated block (or <em>NULL</em>). </td></tr>
|
|
<tr><td class="paramname">count</td><td>The number of elements. </td></tr>
|
|
<tr><td class="paramname">size</td><td>The size of each element. </td></tr>
|
|
</table>
|
|
</dd>
|
|
</dl>
|
|
<dl class="section return"><dt>Returns</dt><dd>A pointer to a re-allocated block of <em>count</em> * <em>size</em> bytes, or <em>NULL</em> if out of memory or if <em>count</em> * <em>size</em> overflows.</dd></dl>
|
|
<p>If there is no overflow, it behaves exactly like <code>mi_realloc(p,count*size)</code>. </p><dl class="section see"><dt>See also</dt><dd><a href="http://man.openbsd.org/reallocarray">reallocarray()</a> (on BSD) </dd></dl>
|
|
|
|
</div>
|
|
</div>
|
|
<a id="ga94c3afcc086e85d75a57e9f76b9b71dd" name="ga94c3afcc086e85d75a57e9f76b9b71dd"></a>
|
|
<h2 class="memtitle"><span class="permalink"><a href="#ga94c3afcc086e85d75a57e9f76b9b71dd">◆ </a></span>mi_realpath()</h2>
|
|
|
|
<div class="memitem">
|
|
<div class="memproto">
|
|
<table class="memname">
|
|
<tr>
|
|
<td class="memname">char * mi_realpath </td>
|
|
<td>(</td>
|
|
<td class="paramtype">const char *</td> <td class="paramname"><span class="paramname"><em>fname</em></span>, </td>
|
|
</tr>
|
|
<tr>
|
|
<td class="paramkey"></td>
|
|
<td></td>
|
|
<td class="paramtype">char *</td> <td class="paramname"><span class="paramname"><em>resolved_name</em></span> )</td>
|
|
</tr>
|
|
</table>
|
|
</div><div class="memdoc">
|
|
|
|
<p>Resolve a file path name. </p>
|
|
<dl class="params"><dt>Parameters</dt><dd>
|
|
<table class="params">
|
|
<tr><td class="paramname">fname</td><td>File name. </td></tr>
|
|
<tr><td class="paramname">resolved_name</td><td>Should be <em>NULL</em> (but can also point to a buffer of at least <em>PATH_MAX</em> bytes). </td></tr>
|
|
</table>
|
|
</dd>
|
|
</dl>
|
|
<dl class="section return"><dt>Returns</dt><dd>If successful a pointer to the resolved absolute file name, or <em>NULL</em> on failure (with <em>errno</em> set to the error code).</dd></dl>
|
|
<p>If <em>resolved_name</em> was <em>NULL</em>, the returned result should be freed with <a class="el" href="#gaf2c7b89c327d1f60f59e68b9ea644d95" title="Free previously allocated memory.">mi_free()</a>.</p>
|
|
<p>Replacement for the standard <a href="http://pubs.opengroup.org/onlinepubs/9699919799/functions/realpath.html">realpath()</a> such that <a class="el" href="#gaf2c7b89c327d1f60f59e68b9ea644d95" title="Free previously allocated memory.">mi_free()</a> can be used on the returned result (if <em>resolved_name</em> was <em>NULL</em>). </p>
|
|
|
|
</div>
|
|
</div>
|
|
<a id="ga23a0fbb452b5dce8e31fab1a1958cacc" name="ga23a0fbb452b5dce8e31fab1a1958cacc"></a>
|
|
<h2 class="memtitle"><span class="permalink"><a href="#ga23a0fbb452b5dce8e31fab1a1958cacc">◆ </a></span>mi_recalloc()</h2>
|
|
|
|
<div class="memitem">
|
|
<div class="memproto">
|
|
<table class="memname">
|
|
<tr>
|
|
<td class="memname">void * mi_recalloc </td>
|
|
<td>(</td>
|
|
<td class="paramtype">void *</td> <td class="paramname"><span class="paramname"><em>p</em></span>, </td>
|
|
</tr>
|
|
<tr>
|
|
<td class="paramkey"></td>
|
|
<td></td>
|
|
<td class="paramtype">size_t</td> <td class="paramname"><span class="paramname"><em>count</em></span>, </td>
|
|
</tr>
|
|
<tr>
|
|
<td class="paramkey"></td>
|
|
<td></td>
|
|
<td class="paramtype">size_t</td> <td class="paramname"><span class="paramname"><em>size</em></span> )</td>
|
|
</tr>
|
|
</table>
|
|
</div><div class="memdoc">
|
|
|
|
<p>Re-allocate memory to <em>count</em> elements of <em>size</em> bytes, with extra memory initialized to zero. </p>
|
|
<dl class="params"><dt>Parameters</dt><dd>
|
|
<table class="params">
|
|
<tr><td class="paramname">p</td><td>Pointer to a previously allocated block (or <em>NULL</em>). </td></tr>
|
|
<tr><td class="paramname">count</td><td>The number of elements. </td></tr>
|
|
<tr><td class="paramname">size</td><td>The size of each element. </td></tr>
|
|
</table>
|
|
</dd>
|
|
</dl>
|
|
<dl class="section return"><dt>Returns</dt><dd>A pointer to a re-allocated block of <em>count</em> * <em>size</em> bytes, or <em>NULL</em> if out of memory or if <em>count</em> * <em>size</em> overflows.</dd></dl>
|
|
<p>If there is no overflow, it behaves exactly like <code>mi_rezalloc(p,count*size)</code>. </p><dl class="section see"><dt>See also</dt><dd><a class="el" href="#ga8bddfb4a1270a0854bbcf44cb3980467" title="Re-allocate memory to count elements of size bytes.">mi_reallocn()</a> </dd>
|
|
<dd>
|
|
<a href="http://man.openbsd.org/reallocarray">recallocarray()</a> (on BSD). </dd></dl>
|
|
|
|
</div>
|
|
</div>
|
|
<a id="ga245ac90ebc2cfdd17de599e5fea59889" name="ga245ac90ebc2cfdd17de599e5fea59889"></a>
|
|
<h2 class="memtitle"><span class="permalink"><a href="#ga245ac90ebc2cfdd17de599e5fea59889">◆ </a></span>mi_strdup()</h2>
|
|
|
|
<div class="memitem">
|
|
<div class="memproto">
|
|
<table class="memname">
|
|
<tr>
|
|
<td class="memname">char * mi_strdup </td>
|
|
<td>(</td>
|
|
<td class="paramtype">const char *</td> <td class="paramname"><span class="paramname"><em>s</em></span></td><td>)</td>
|
|
<td></td>
|
|
</tr>
|
|
</table>
|
|
</div><div class="memdoc">
|
|
|
|
<p>Allocate and duplicate a string. </p>
|
|
<dl class="params"><dt>Parameters</dt><dd>
|
|
<table class="params">
|
|
<tr><td class="paramname">s</td><td>string to duplicate (or <em>NULL</em>). </td></tr>
|
|
</table>
|
|
</dd>
|
|
</dl>
|
|
<dl class="section return"><dt>Returns</dt><dd>a pointer to newly allocated memory initialized to string <em>s</em>, or <em>NULL</em> if either out of memory or if <em>s</em> is <em>NULL</em>.</dd></dl>
|
|
<p>Replacement for the standard <a href="http://pubs.opengroup.org/onlinepubs/9699919799/functions/strdup.html">strdup()</a> such that <a class="el" href="#gaf2c7b89c327d1f60f59e68b9ea644d95" title="Free previously allocated memory.">mi_free()</a> can be used on the returned result. </p>
|
|
|
|
</div>
|
|
</div>
|
|
<a id="ga486d0d26b3b3794f6d1cdb41a9aed92d" name="ga486d0d26b3b3794f6d1cdb41a9aed92d"></a>
|
|
<h2 class="memtitle"><span class="permalink"><a href="#ga486d0d26b3b3794f6d1cdb41a9aed92d">◆ </a></span>mi_strndup()</h2>
|
|
|
|
<div class="memitem">
|
|
<div class="memproto">
|
|
<table class="memname">
|
|
<tr>
|
|
<td class="memname">char * mi_strndup </td>
|
|
<td>(</td>
|
|
<td class="paramtype">const char *</td> <td class="paramname"><span class="paramname"><em>s</em></span>, </td>
|
|
</tr>
|
|
<tr>
|
|
<td class="paramkey"></td>
|
|
<td></td>
|
|
<td class="paramtype">size_t</td> <td class="paramname"><span class="paramname"><em>n</em></span> )</td>
|
|
</tr>
|
|
</table>
|
|
</div><div class="memdoc">
|
|
|
|
<p>Allocate and duplicate a string up to <em>n</em> bytes. </p>
|
|
<dl class="params"><dt>Parameters</dt><dd>
|
|
<table class="params">
|
|
<tr><td class="paramname">s</td><td>string to duplicate (or <em>NULL</em>). </td></tr>
|
|
<tr><td class="paramname">n</td><td>maximum number of bytes to copy (excluding the terminating zero). </td></tr>
|
|
</table>
|
|
</dd>
|
|
</dl>
|
|
<dl class="section return"><dt>Returns</dt><dd>a pointer to newly allocated memory initialized to string <em>s</em> up to the first <em>n</em> bytes (and always zero terminated), or <em>NULL</em> if either out of memory or if <em>s</em> is <em>NULL</em>.</dd></dl>
|
|
<p>Replacement for the standard <a href="http://pubs.opengroup.org/onlinepubs/9699919799/functions/strndup.html">strndup()</a> such that <a class="el" href="#gaf2c7b89c327d1f60f59e68b9ea644d95" title="Free previously allocated memory.">mi_free()</a> can be used on the returned result. </p>
|
|
|
|
</div>
|
|
</div>
|
|
<a id="gae6e38c4403247a7b40d80419e093bfb8" name="gae6e38c4403247a7b40d80419e093bfb8"></a>
|
|
<h2 class="memtitle"><span class="permalink"><a href="#gae6e38c4403247a7b40d80419e093bfb8">◆ </a></span>mi_zalloc()</h2>
|
|
|
|
<div class="memitem">
|
|
<div class="memproto">
|
|
<table class="memname">
|
|
<tr>
|
|
<td class="memname">void * mi_zalloc </td>
|
|
<td>(</td>
|
|
<td class="paramtype">size_t</td> <td class="paramname"><span class="paramname"><em>size</em></span></td><td>)</td>
|
|
<td></td>
|
|
</tr>
|
|
</table>
|
|
</div><div class="memdoc">
|
|
|
|
<p>Allocate zero-initialized <code>size</code> bytes. </p>
|
|
<dl class="params"><dt>Parameters</dt><dd>
|
|
<table class="params">
|
|
<tr><td class="paramname">size</td><td>The size in bytes. </td></tr>
|
|
</table>
|
|
</dd>
|
|
</dl>
|
|
<dl class="section return"><dt>Returns</dt><dd>Pointer to newly allocated zero initialized memory, or <em>NULL</em> if out of memory. </dd></dl>
|
|
|
|
</div>
|
|
</div>
|
|
</div><!-- contents -->
|
|
</div><!-- doc-content -->
|
|
<!-- start footer part -->
|
|
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
|
|
<ul>
|
|
<li class="footer">Generated by <a href="https://www.doxygen.org/index.html"><img class="footer" src="doxygen.svg" width="104" height="31" alt="doxygen"/></a> 1.11.0 </li>
|
|
</ul>
|
|
</div>
|
|
</body>
|
|
</html>
|