2019-07-08 17:15:34 -07:00
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
2024-06-04 14:37:16 -07:00
< html xmlns = "http://www.w3.org/1999/xhtml" lang = "en-US" >
2019-06-22 10:30:09 -07:00
< head >
< meta http-equiv = "Content-Type" content = "text/xhtml;charset=UTF-8" / >
2024-06-04 14:37:16 -07:00
< meta http-equiv = "X-UA-Compatible" content = "IE=11" / >
2025-01-03 17:56:15 -08:00
< meta name = "generator" content = "Doxygen 1.13.1" / >
2019-06-22 10:30:09 -07:00
< 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 >
2024-06-04 14:37:16 -07:00
< script type = "text/javascript" src = "clipboard.js" > < / script >
2019-06-22 10:30:09 -07:00
< 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 >
2024-06-04 14:37:16 -07:00
< script type = "text/javascript" src = "resize.js" > < / script >
< script type = "text/javascript" src = "cookie.js" > < / script >
2019-06-22 10:30:09 -07:00
< 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" >
2024-06-04 14:37:16 -07:00
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&dn=expat.txt MIT */
$ ( function ( ) { init _search ( ) ; } ) ;
2019-06-22 10:30:09 -07:00
/* @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 >
2024-06-04 14:37:16 -07:00
< tr id = "projectrow" >
2019-06-22 10:30:09 -07:00
< td id = "projectlogo" > < img alt = "Logo" src = "mimalloc-logo.svg" / > < / td >
2024-06-04 14:37:16 -07:00
< td id = "projectalign" >
< div id = "projectname" > mi-malloc< span id = "projectnumber" >   1.8/2.1< / span >
2019-06-22 10:30:09 -07:00
< / div >
< / td >
2024-06-04 14:37:16 -07:00
< td > < div id = "MSearchBox" class = "MSearchBoxInactive" >
2019-06-22 10:30:09 -07:00
< span class = "left" >
2024-06-04 14:37:16 -07:00
< 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)"
2019-06-22 10:30:09 -07:00
onkeyup = "searchBox.OnSearchFieldChange(event)" / >
< / span > < span class = "right" >
2021-12-18 16:36:37 -08:00
< a id = "MSearchClose" href = "javascript:searchBox.CloseResultsWindow()" > < img id = "MSearchCloseImg" border = "0" src = "search/close.svg" alt = "" / > < / a >
2019-06-22 10:30:09 -07:00
< / span >
< / div >
< / td >
< / tr >
< / tbody >
< / table >
< / div >
<!-- end header part -->
2025-01-03 17:56:15 -08:00
<!-- Generated by Doxygen 1.13.1 -->
2019-06-22 10:30:09 -07:00
< script type = "text/javascript" >
2024-06-04 14:37:16 -07:00
/* @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 ) ; } ) ;
2019-06-22 10:30:09 -07:00
/* @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 >
2024-06-04 14:37:16 -07:00
< div id = "splitbar" style = "-moz-user-select:none;"
2019-06-22 10:30:09 -07:00
class = "ui-resizable-handle" >
< / div >
< / div >
< script type = "text/javascript" >
2024-06-04 14:37:16 -07:00
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&dn=expat.txt MIT */
$ ( function ( ) { initNavTree ( 'group__malloc.html' , '' ) ; initResizable ( true ) ; } ) ;
2019-06-22 10:30:09 -07:00
/* @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" >
2024-06-04 14:37:16 -07:00
< 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 >
2019-06-22 10:30:09 -07:00
< / div >
< div class = "header" >
< div class = "summary" >
< a href = "#func-members" > Functions< / a > < / div >
2024-06-04 14:37:16 -07:00
< div class = "headertitle" > < div class = "title" > Basic Allocation< / div > < / div >
2019-06-22 10:30:09 -07:00
< / div > <!-- header -->
< div class = "contents" >
2024-06-04 14:37:16 -07:00
< p > The basic allocation interface.
2019-06-22 10:30:09 -07:00
< a href = "#details" > More...< / a > < / p >
< table class = "memberdecls" >
2024-06-04 14:37:16 -07:00
< tr class = "heading" > < td colspan = "2" > < h2 class = "groupheader" > < a id = "func-members" name = "func-members" > < / a >
2019-06-22 10:30:09 -07:00
Functions< / h2 > < / td > < / tr >
2024-06-04 14:37:16 -07:00
< 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 >
2019-06-22 10:30:09 -07:00
< tr class = "separator:gaf2c7b89c327d1f60f59e68b9ea644d95" > < td class = "memSeparator" colspan = "2" >   < / td > < / tr >
2024-06-04 14:37:16 -07:00
< 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 >
2025-01-03 17:56:15 -08:00
< tr class = "memdesc:gae1dd97b542420c87ae085e822b1229e8" > < td class = "mdescLeft" >   < / td > < td class = "mdescRight" > Allocate < em class = "arg" > size< / em > bytes. < br / > < / td > < / tr >
2024-06-04 14:37:16 -07:00
< 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 >
2025-01-03 17:56:15 -08:00
< tr class = "memdesc:ga6686568014b54d1e6c7ac64a076e4f56" > < td class = "mdescLeft" >   < / td > < td class = "mdescRight" > Allocate zero-initialized < em class = "arg" > count< / em > elements of < em class = "arg" > size< / em > bytes. < br / > < / td > < / tr >
2024-06-04 14:37:16 -07:00
< 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 >
2025-01-03 17:56:15 -08:00
< tr class = "memdesc:ga0621af6a5e3aa384e6a1b548958bf583" > < td class = "mdescLeft" >   < / td > < td class = "mdescRight" > Re-allocate memory to < em class = "arg" > newsize< / em > bytes. < br / > < / td > < / tr >
2024-06-04 14:37:16 -07:00
< 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 >
2025-01-03 17:56:15 -08:00
< tr class = "memdesc:ga23a0fbb452b5dce8e31fab1a1958cacc" > < td class = "mdescLeft" >   < / td > < td class = "mdescRight" > Re-allocate memory to < em class = "arg" > count< / em > elements of < em class = "arg" > size< / em > bytes, with extra memory initialized to zero. < br / > < / td > < / tr >
2019-07-08 17:15:34 -07:00
< tr class = "separator:ga23a0fbb452b5dce8e31fab1a1958cacc" > < td class = "memSeparator" colspan = "2" >   < / td > < / tr >
2024-06-04 14:37:16 -07:00
< 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 >
2025-01-03 17:56:15 -08:00
< tr class = "memdesc:ga19299856216cfbb08e2628593654dfb0" > < td class = "mdescLeft" >   < / td > < td class = "mdescRight" > Try to re-allocate memory to < em class = "arg" > newsize< / em > bytes < em > in place< / em > . < br / > < / td > < / tr >
2024-06-04 14:37:16 -07:00
< 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 >
2025-01-03 17:56:15 -08:00
< tr class = "memdesc:ga61f46bade3db76ca24aaafedc40de7b6" > < td class = "mdescLeft" >   < / td > < td class = "mdescRight" > Allocate < em class = "arg" > count< / em > elements of < em class = "arg" > size< / em > bytes. < br / > < / td > < / tr >
2024-06-04 14:37:16 -07:00
< 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 >
2025-01-03 17:56:15 -08:00
< tr class = "memdesc:ga8bddfb4a1270a0854bbcf44cb3980467" > < td class = "mdescLeft" >   < / td > < td class = "mdescRight" > Re-allocate memory to < em class = "arg" > count< / em > elements of < em class = "arg" > size< / em > bytes. < br / > < / td > < / tr >
2024-06-04 14:37:16 -07:00
< 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 >
2025-01-03 17:56:15 -08:00
< tr class = "memdesc:ga4dc3a4067037b151a64629fe8a332641" > < td class = "mdescLeft" >   < / td > < td class = "mdescRight" > Re-allocate memory to < em class = "arg" > newsize< / em > bytes,. < br / > < / td > < / tr >
2024-06-04 14:37:16 -07:00
< 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 >
2025-01-03 17:56:15 -08:00
< tr class = "memdesc:ga486d0d26b3b3794f6d1cdb41a9aed92d" > < td class = "mdescLeft" >   < / td > < td class = "mdescRight" > Allocate and duplicate a string up to < em class = "arg" > n< / em > bytes. < br / > < / td > < / tr >
2024-06-04 14:37:16 -07:00
< 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 >
2019-06-22 10:30:09 -07:00
< / 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 >
2024-06-04 14:37:16 -07:00
< a id = "ga6686568014b54d1e6c7ac64a076e4f56" name = "ga6686568014b54d1e6c7ac64a076e4f56" > < / a >
< h2 class = "memtitle" > < span class = "permalink" > < a href = "#ga6686568014b54d1e6c7ac64a076e4f56" > ◆   < / a > < / span > mi_calloc()< / h2 >
2019-06-22 10:30:09 -07:00
< div class = "memitem" >
< div class = "memproto" >
< table class = "memname" >
< tr >
2024-06-04 14:37:16 -07:00
< td class = "memname" > void * mi_calloc < / td >
2019-06-22 10:30:09 -07:00
< td > (< / td >
2024-06-04 14:37:16 -07:00
< td class = "paramtype" > size_t< / td > < td class = "paramname" > < span class = "paramname" > < em > count< / em > < / span > , < / td >
2019-06-22 10:30:09 -07:00
< / tr >
< tr >
< td class = "paramkey" > < / td >
< td > < / td >
2024-06-04 14:37:16 -07:00
< td class = "paramtype" > size_t< / td > < td class = "paramname" > < span class = "paramname" > < em > size< / em > < / span >   )< / td >
2019-06-22 10:30:09 -07:00
< / tr >
< / table >
< / div > < div class = "memdoc" >
2025-01-03 17:56:15 -08:00
< p > Allocate zero-initialized < em class = "arg" > count< / em > elements of < em class = "arg" > size< / em > bytes. < / p >
2019-06-22 10:30:09 -07:00
< 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 >
2025-01-03 17:56:15 -08:00
< dl class = "section return" > < dt > Returns< / dt > < dd > pointer to the allocated memory of < em class = "arg" > size*< em class = "arg" > count< / em > bytes< / em > , or < em class = "arg" > 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 class = "arg" > size< / em > or < em class = "arg" > 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 >
2019-06-22 10:30:09 -07:00
< / div >
< / div >
2024-06-04 14:37:16 -07:00
< a id = "ga19299856216cfbb08e2628593654dfb0" name = "ga19299856216cfbb08e2628593654dfb0" > < / a >
< h2 class = "memtitle" > < span class = "permalink" > < a href = "#ga19299856216cfbb08e2628593654dfb0" > ◆   < / a > < / span > mi_expand()< / h2 >
2019-06-22 10:30:09 -07:00
< div class = "memitem" >
< div class = "memproto" >
< table class = "memname" >
< tr >
2024-06-04 14:37:16 -07:00
< td class = "memname" > void * mi_expand < / td >
2019-06-22 10:30:09 -07:00
< td > (< / td >
2024-06-04 14:37:16 -07:00
< td class = "paramtype" > void *< / td > < td class = "paramname" > < span class = "paramname" > < em > p< / em > < / span > , < / td >
2019-06-22 10:30:09 -07:00
< / tr >
< tr >
< td class = "paramkey" > < / td >
< td > < / td >
2024-06-04 14:37:16 -07:00
< td class = "paramtype" > size_t< / td > < td class = "paramname" > < span class = "paramname" > < em > newsize< / em > < / span >   )< / td >
2019-06-22 10:30:09 -07:00
< / tr >
< / table >
< / div > < div class = "memdoc" >
2025-01-03 17:56:15 -08:00
< p > Try to re-allocate memory to < em class = "arg" > newsize< / em > bytes < em > in place< / em > . < / p >
2019-06-22 10:30:09 -07:00
< dl class = "params" > < dt > Parameters< / dt > < dd >
< table class = "params" >
2025-01-03 17:56:15 -08:00
< tr > < td class = "paramname" > p< / td > < td > pointer to previously allocated memory (or < em class = "arg" > NULL< / em > ). < / td > < / tr >
2019-06-22 10:30:09 -07:00
< tr > < td class = "paramname" > newsize< / td > < td > the new required size in bytes. < / td > < / tr >
< / table >
< / dd >
< / dl >
2025-01-03 17:56:15 -08:00
< dl class = "section return" > < dt > Returns< / dt > < dd > pointer to the re-allocated memory of < em class = "arg" > newsize< / em > bytes (always equal to < em class = "arg" > p< / em > ), or < em class = "arg" > NULL< / em > if either out of memory or if the memory could not be expanded in place. If < em class = "arg" > NULL< / em > is returned, the pointer < em class = "arg" > 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 class = "arg" > newsize< / em > is larger than the original < em class = "arg" > size< / em > allocated for < em class = "arg" > p< / em > , the bytes after < em class = "arg" > size< / em > are uninitialized. < / dd > < / dl >
2019-06-22 10:30:09 -07:00
< / div >
< / div >
2024-06-04 14:37:16 -07:00
< a id = "gaf2c7b89c327d1f60f59e68b9ea644d95" name = "gaf2c7b89c327d1f60f59e68b9ea644d95" > < / a >
< h2 class = "memtitle" > < span class = "permalink" > < a href = "#gaf2c7b89c327d1f60f59e68b9ea644d95" > ◆   < / a > < / span > mi_free()< / h2 >
2019-06-22 10:30:09 -07:00
< div class = "memitem" >
< div class = "memproto" >
< table class = "memname" >
< tr >
< td class = "memname" > void mi_free < / td >
< td > (< / td >
2024-06-04 14:37:16 -07:00
< td class = "paramtype" > void *< / td > < td class = "paramname" > < span class = "paramname" > < em > p< / em > < / span > < / td > < td > )< / td >
2019-06-22 10:30:09 -07:00
< td > < / td >
< / tr >
< / table >
< / div > < div class = "memdoc" >
< p > Free previously allocated memory. < / p >
2025-01-03 17:56:15 -08:00
< p > The pointer < code > p< / code > must have been allocated before (or be < em class = "arg" > NULL< / em > ). < / p > < dl class = "params" > < dt > Parameters< / dt > < dd >
2019-06-22 10:30:09 -07:00
< table class = "params" >
2025-01-03 17:56:15 -08:00
< tr > < td class = "paramname" > p< / td > < td > pointer to free, or < em class = "arg" > NULL< / em > . < / td > < / tr >
2019-06-22 10:30:09 -07:00
< / table >
< / dd >
< / dl >
< / div >
< / div >
2024-06-04 14:37:16 -07:00
< a id = "gae1dd97b542420c87ae085e822b1229e8" name = "gae1dd97b542420c87ae085e822b1229e8" > < / a >
< h2 class = "memtitle" > < span class = "permalink" > < a href = "#gae1dd97b542420c87ae085e822b1229e8" > ◆   < / a > < / span > mi_malloc()< / h2 >
2019-06-22 10:30:09 -07:00
< div class = "memitem" >
< div class = "memproto" >
< table class = "memname" >
< tr >
2024-06-04 14:37:16 -07:00
< td class = "memname" > void * mi_malloc < / td >
2019-06-22 10:30:09 -07:00
< td > (< / td >
2024-06-04 14:37:16 -07:00
< td class = "paramtype" > size_t< / td > < td class = "paramname" > < span class = "paramname" > < em > size< / em > < / span > < / td > < td > )< / td >
2019-06-22 10:30:09 -07:00
< td > < / td >
< / tr >
< / table >
< / div > < div class = "memdoc" >
2025-01-03 17:56:15 -08:00
< p > Allocate < em class = "arg" > size< / em > bytes. < / p >
2019-06-22 10:30:09 -07:00
< 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 >
2025-01-03 17:56:15 -08:00
< dl class = "section return" > < dt > Returns< / dt > < dd > pointer to the allocated memory or < em class = "arg" > NULL< / em > if out of memory. Returns a unique pointer if called with < em class = "arg" > size< / em > 0. < / dd > < / dl >
2019-06-22 10:30:09 -07:00
< / div >
< / div >
2024-06-04 14:37:16 -07:00
< a id = "ga61f46bade3db76ca24aaafedc40de7b6" name = "ga61f46bade3db76ca24aaafedc40de7b6" > < / a >
< h2 class = "memtitle" > < span class = "permalink" > < a href = "#ga61f46bade3db76ca24aaafedc40de7b6" > ◆   < / a > < / span > mi_mallocn()< / h2 >
2019-06-22 10:30:09 -07:00
< div class = "memitem" >
< div class = "memproto" >
< table class = "memname" >
< tr >
2024-06-04 14:37:16 -07:00
< td class = "memname" > void * mi_mallocn < / td >
2019-06-22 10:30:09 -07:00
< td > (< / td >
2024-06-04 14:37:16 -07:00
< td class = "paramtype" > size_t< / td > < td class = "paramname" > < span class = "paramname" > < em > count< / em > < / span > , < / td >
2019-06-22 10:30:09 -07:00
< / tr >
< tr >
< td class = "paramkey" > < / td >
< td > < / td >
2024-06-04 14:37:16 -07:00
< td class = "paramtype" > size_t< / td > < td class = "paramname" > < span class = "paramname" > < em > size< / em > < / span >   )< / td >
2019-06-22 10:30:09 -07:00
< / tr >
< / table >
< / div > < div class = "memdoc" >
2025-01-03 17:56:15 -08:00
< p > Allocate < em class = "arg" > count< / em > elements of < em class = "arg" > size< / em > bytes. < / p >
2019-06-22 10:30:09 -07:00
< 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 >
2025-01-03 17:56:15 -08:00
< dl class = "section return" > < dt > Returns< / dt > < dd > A pointer to a block of < em class = "arg" > count< / em > * < em class = "arg" > size< / em > bytes, or < em class = "arg" > NULL< / em > if out of memory or if < em class = "arg" > count< / em > * < em class = "arg" > size< / em > overflows.< / dd > < / dl >
2024-06-04 14:37:16 -07:00
< 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 >
2019-06-22 10:30:09 -07:00
< dd >
mi_zallocn() < / dd > < / dl >
< / div >
< / div >
2024-06-04 14:37:16 -07:00
< a id = "ga0621af6a5e3aa384e6a1b548958bf583" name = "ga0621af6a5e3aa384e6a1b548958bf583" > < / a >
< h2 class = "memtitle" > < span class = "permalink" > < a href = "#ga0621af6a5e3aa384e6a1b548958bf583" > ◆   < / a > < / span > mi_realloc()< / h2 >
2019-06-22 10:30:09 -07:00
< div class = "memitem" >
< div class = "memproto" >
< table class = "memname" >
< tr >
2024-06-04 14:37:16 -07:00
< td class = "memname" > void * mi_realloc < / td >
2019-06-22 10:30:09 -07:00
< td > (< / td >
2024-06-04 14:37:16 -07:00
< td class = "paramtype" > void *< / td > < td class = "paramname" > < span class = "paramname" > < em > p< / em > < / span > , < / td >
2019-06-22 10:30:09 -07:00
< / tr >
< tr >
< td class = "paramkey" > < / td >
< td > < / td >
2024-06-04 14:37:16 -07:00
< td class = "paramtype" > size_t< / td > < td class = "paramname" > < span class = "paramname" > < em > newsize< / em > < / span >   )< / td >
2019-06-22 10:30:09 -07:00
< / tr >
< / table >
< / div > < div class = "memdoc" >
2025-01-03 17:56:15 -08:00
< p > Re-allocate memory to < em class = "arg" > newsize< / em > bytes. < / p >
2019-06-22 10:30:09 -07:00
< dl class = "params" > < dt > Parameters< / dt > < dd >
< table class = "params" >
2025-01-03 17:56:15 -08:00
< tr > < td class = "paramname" > p< / td > < td > pointer to previously allocated memory (or < em class = "arg" > NULL< / em > ). < / td > < / tr >
2019-06-22 10:30:09 -07:00
< tr > < td class = "paramname" > newsize< / td > < td > the new required size in bytes. < / td > < / tr >
< / table >
< / dd >
< / dl >
2025-01-03 17:56:15 -08:00
< dl class = "section return" > < dt > Returns< / dt > < dd > pointer to the re-allocated memory of < em class = "arg" > newsize< / em > bytes, or < em class = "arg" > NULL< / em > if out of memory. If < em class = "arg" > NULL< / em > is returned, the pointer < em class = "arg" > 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 class = "arg" > p< / em > is < em class = "arg" > NULL< / em > , it behaves as < em class = "arg" > mi_malloc< / em > (< em class = "arg" > newsize< / em > ). If < em class = "arg" > newsize< / em > is larger than the original < em class = "arg" > size< / em > allocated for < em class = "arg" > p< / em > , the bytes after < em class = "arg" > size< / em > are uninitialized. < / dd > < / dl >
2019-06-22 10:30:09 -07:00
< / div >
< / div >
2024-06-04 14:37:16 -07:00
< a id = "ga4dc3a4067037b151a64629fe8a332641" name = "ga4dc3a4067037b151a64629fe8a332641" > < / a >
< h2 class = "memtitle" > < span class = "permalink" > < a href = "#ga4dc3a4067037b151a64629fe8a332641" > ◆   < / a > < / span > mi_reallocf()< / h2 >
2019-06-22 10:30:09 -07:00
< div class = "memitem" >
< div class = "memproto" >
< table class = "memname" >
< tr >
2024-06-04 14:37:16 -07:00
< td class = "memname" > void * mi_reallocf < / td >
2019-06-22 10:30:09 -07:00
< td > (< / td >
2024-06-04 14:37:16 -07:00
< td class = "paramtype" > void *< / td > < td class = "paramname" > < span class = "paramname" > < em > p< / em > < / span > , < / td >
2019-06-22 10:30:09 -07:00
< / tr >
< tr >
< td class = "paramkey" > < / td >
< td > < / td >
2024-06-04 14:37:16 -07:00
< td class = "paramtype" > size_t< / td > < td class = "paramname" > < span class = "paramname" > < em > newsize< / em > < / span >   )< / td >
2019-06-22 10:30:09 -07:00
< / tr >
< / table >
< / div > < div class = "memdoc" >
2025-01-03 17:56:15 -08:00
< p > Re-allocate memory to < em class = "arg" > newsize< / em > bytes,. < / p >
2019-06-22 10:30:09 -07:00
< dl class = "params" > < dt > Parameters< / dt > < dd >
< table class = "params" >
2025-01-03 17:56:15 -08:00
< tr > < td class = "paramname" > p< / td > < td > pointer to previously allocated memory (or < em class = "arg" > NULL< / em > ). < / td > < / tr >
2019-06-22 10:30:09 -07:00
< tr > < td class = "paramname" > newsize< / td > < td > the new required size in bytes. < / td > < / tr >
< / table >
< / dd >
< / dl >
2025-01-03 17:56:15 -08:00
< dl class = "section return" > < dt > Returns< / dt > < dd > pointer to the re-allocated memory of < em class = "arg" > newsize< / em > bytes, or < em class = "arg" > 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 class = "arg" > NULL< / em > is returned, the original pointer < em class = "arg" > p< / em > is freed (if it was not < em class = "arg" > 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 class = "arg" > p< / em > is < em class = "arg" > NULL< / em > , it behaves as < em class = "arg" > mi_malloc< / em > (< em class = "arg" > newsize< / em > ). If < em class = "arg" > newsize< / em > is larger than the original < em class = "arg" > size< / em > allocated for < em class = "arg" > p< / em > , the bytes after < em class = "arg" > size< / em > are uninitialized.< / p >
2019-06-22 10:30:09 -07:00
< 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 >
2024-06-04 14:37:16 -07:00
< a id = "ga8bddfb4a1270a0854bbcf44cb3980467" name = "ga8bddfb4a1270a0854bbcf44cb3980467" > < / a >
< h2 class = "memtitle" > < span class = "permalink" > < a href = "#ga8bddfb4a1270a0854bbcf44cb3980467" > ◆   < / a > < / span > mi_reallocn()< / h2 >
2019-06-22 10:30:09 -07:00
< div class = "memitem" >
< div class = "memproto" >
< table class = "memname" >
< tr >
2024-06-04 14:37:16 -07:00
< td class = "memname" > void * mi_reallocn < / td >
2019-06-22 10:30:09 -07:00
< td > (< / td >
2024-06-04 14:37:16 -07:00
< td class = "paramtype" > void *< / td > < td class = "paramname" > < span class = "paramname" > < em > p< / em > < / span > , < / td >
2019-06-22 10:30:09 -07:00
< / tr >
< tr >
< td class = "paramkey" > < / td >
< td > < / td >
2024-06-04 14:37:16 -07:00
< td class = "paramtype" > size_t< / td > < td class = "paramname" > < span class = "paramname" > < em > count< / em > < / span > , < / td >
2019-06-22 10:30:09 -07:00
< / tr >
< tr >
< td class = "paramkey" > < / td >
< td > < / td >
2024-06-04 14:37:16 -07:00
< td class = "paramtype" > size_t< / td > < td class = "paramname" > < span class = "paramname" > < em > size< / em > < / span >   )< / td >
2019-06-22 10:30:09 -07:00
< / tr >
< / table >
< / div > < div class = "memdoc" >
2025-01-03 17:56:15 -08:00
< p > Re-allocate memory to < em class = "arg" > count< / em > elements of < em class = "arg" > size< / em > bytes. < / p >
2019-06-22 10:30:09 -07:00
< dl class = "params" > < dt > Parameters< / dt > < dd >
< table class = "params" >
2025-01-03 17:56:15 -08:00
< tr > < td class = "paramname" > p< / td > < td > Pointer to a previously allocated block (or < em class = "arg" > NULL< / em > ). < / td > < / tr >
2019-06-22 10:30:09 -07:00
< 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 >
2025-01-03 17:56:15 -08:00
< dl class = "section return" > < dt > Returns< / dt > < dd > A pointer to a re-allocated block of < em class = "arg" > count< / em > * < em class = "arg" > size< / em > bytes, or < em class = "arg" > NULL< / em > if out of memory or if < em class = "arg" > count< / em > * < em class = "arg" > size< / em > overflows.< / dd > < / dl >
2019-07-08 17:15:34 -07:00
< 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 >
2019-06-22 10:30:09 -07:00
< / div >
< / div >
2024-06-04 14:37:16 -07:00
< a id = "ga94c3afcc086e85d75a57e9f76b9b71dd" name = "ga94c3afcc086e85d75a57e9f76b9b71dd" > < / a >
< h2 class = "memtitle" > < span class = "permalink" > < a href = "#ga94c3afcc086e85d75a57e9f76b9b71dd" > ◆   < / a > < / span > mi_realpath()< / h2 >
2019-06-22 10:30:09 -07:00
< div class = "memitem" >
< div class = "memproto" >
< table class = "memname" >
< tr >
2024-06-04 14:37:16 -07:00
< td class = "memname" > char * mi_realpath < / td >
2019-06-22 10:30:09 -07:00
< td > (< / td >
2024-06-04 14:37:16 -07:00
< td class = "paramtype" > const char *< / td > < td class = "paramname" > < span class = "paramname" > < em > fname< / em > < / span > , < / td >
2019-06-22 10:30:09 -07:00
< / tr >
< tr >
< td class = "paramkey" > < / td >
< td > < / td >
2024-06-04 14:37:16 -07:00
< td class = "paramtype" > char *< / td > < td class = "paramname" > < span class = "paramname" > < em > resolved_name< / em > < / span >   )< / td >
2019-06-22 10:30:09 -07:00
< / 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 >
2025-01-03 17:56:15 -08:00
< tr > < td class = "paramname" > resolved_name< / td > < td > Should be < em class = "arg" > NULL< / em > (but can also point to a buffer of at least < em class = "arg" > PATH_MAX< / em > bytes). < / td > < / tr >
2019-06-22 10:30:09 -07:00
< / table >
< / dd >
< / dl >
2025-01-03 17:56:15 -08:00
< dl class = "section return" > < dt > Returns< / dt > < dd > If successful a pointer to the resolved absolute file name, or < em class = "arg" > NULL< / em > on failure (with < em class = "arg" > errno< / em > set to the error code).< / dd > < / dl >
< p > If < em class = "arg" > resolved_name< / em > was < em class = "arg" > 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 class = "arg" > resolved_name< / em > was < em class = "arg" > NULL< / em > ). < / p >
2019-06-22 10:30:09 -07:00
< / div >
< / div >
2024-06-04 14:37:16 -07:00
< a id = "ga23a0fbb452b5dce8e31fab1a1958cacc" name = "ga23a0fbb452b5dce8e31fab1a1958cacc" > < / a >
< h2 class = "memtitle" > < span class = "permalink" > < a href = "#ga23a0fbb452b5dce8e31fab1a1958cacc" > ◆   < / a > < / span > mi_recalloc()< / h2 >
2019-06-22 10:30:09 -07:00
< div class = "memitem" >
< div class = "memproto" >
< table class = "memname" >
< tr >
2019-07-08 17:15:34 -07:00
< td class = "memname" > void * mi_recalloc < / td >
2019-06-22 10:30:09 -07:00
< td > (< / td >
2024-06-04 14:37:16 -07:00
< td class = "paramtype" > void *< / td > < td class = "paramname" > < span class = "paramname" > < em > p< / em > < / span > , < / td >
2019-06-22 10:30:09 -07:00
< / tr >
< tr >
< td class = "paramkey" > < / td >
< td > < / td >
2024-06-04 14:37:16 -07:00
< td class = "paramtype" > size_t< / td > < td class = "paramname" > < span class = "paramname" > < em > count< / em > < / span > , < / td >
2019-06-22 10:30:09 -07:00
< / tr >
< tr >
< td class = "paramkey" > < / td >
< td > < / td >
2024-06-04 14:37:16 -07:00
< td class = "paramtype" > size_t< / td > < td class = "paramname" > < span class = "paramname" > < em > size< / em > < / span >   )< / td >
2019-06-22 10:30:09 -07:00
< / tr >
< / table >
< / div > < div class = "memdoc" >
2025-01-03 17:56:15 -08:00
< p > Re-allocate memory to < em class = "arg" > count< / em > elements of < em class = "arg" > size< / em > bytes, with extra memory initialized to zero. < / p >
2019-06-22 10:30:09 -07:00
< dl class = "params" > < dt > Parameters< / dt > < dd >
< table class = "params" >
2025-01-03 17:56:15 -08:00
< tr > < td class = "paramname" > p< / td > < td > Pointer to a previously allocated block (or < em class = "arg" > NULL< / em > ). < / td > < / tr >
2019-06-22 10:30:09 -07:00
< 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 >
2025-01-03 17:56:15 -08:00
< dl class = "section return" > < dt > Returns< / dt > < dd > A pointer to a re-allocated block of < em class = "arg" > count< / em > * < em class = "arg" > size< / em > bytes, or < em class = "arg" > NULL< / em > if out of memory or if < em class = "arg" > count< / em > * < em class = "arg" > size< / em > overflows.< / dd > < / dl >
2024-06-04 14:37:16 -07:00
< 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 >
2019-06-22 10:30:09 -07:00
< dd >
< a href = "http://man.openbsd.org/reallocarray" > recallocarray()< / a > (on BSD). < / dd > < / dl >
< / div >
< / div >
2024-06-04 14:37:16 -07:00
< a id = "ga245ac90ebc2cfdd17de599e5fea59889" name = "ga245ac90ebc2cfdd17de599e5fea59889" > < / a >
< h2 class = "memtitle" > < span class = "permalink" > < a href = "#ga245ac90ebc2cfdd17de599e5fea59889" > ◆   < / a > < / span > mi_strdup()< / h2 >
2019-06-22 10:30:09 -07:00
< div class = "memitem" >
< div class = "memproto" >
< table class = "memname" >
< tr >
2024-06-04 14:37:16 -07:00
< td class = "memname" > char * mi_strdup < / td >
2019-06-22 10:30:09 -07:00
< td > (< / td >
2024-06-04 14:37:16 -07:00
< td class = "paramtype" > const char *< / td > < td class = "paramname" > < span class = "paramname" > < em > s< / em > < / span > < / td > < td > )< / td >
2019-06-22 10:30:09 -07:00
< 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" >
2025-01-03 17:56:15 -08:00
< tr > < td class = "paramname" > s< / td > < td > string to duplicate (or < em class = "arg" > NULL< / em > ). < / td > < / tr >
2019-06-22 10:30:09 -07:00
< / table >
< / dd >
< / dl >
2025-01-03 17:56:15 -08:00
< dl class = "section return" > < dt > Returns< / dt > < dd > a pointer to newly allocated memory initialized to string < em class = "arg" > s< / em > , or < em class = "arg" > NULL< / em > if either out of memory or if < em class = "arg" > s< / em > is < em class = "arg" > NULL< / em > .< / dd > < / dl >
2024-06-04 14:37:16 -07:00
< 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 >
2019-06-22 10:30:09 -07:00
< / div >
< / div >
2024-06-04 14:37:16 -07:00
< a id = "ga486d0d26b3b3794f6d1cdb41a9aed92d" name = "ga486d0d26b3b3794f6d1cdb41a9aed92d" > < / a >
< h2 class = "memtitle" > < span class = "permalink" > < a href = "#ga486d0d26b3b3794f6d1cdb41a9aed92d" > ◆   < / a > < / span > mi_strndup()< / h2 >
2019-06-22 10:30:09 -07:00
< div class = "memitem" >
< div class = "memproto" >
< table class = "memname" >
< tr >
2024-06-04 14:37:16 -07:00
< td class = "memname" > char * mi_strndup < / td >
2019-06-22 10:30:09 -07:00
< td > (< / td >
2024-06-04 14:37:16 -07:00
< td class = "paramtype" > const char *< / td > < td class = "paramname" > < span class = "paramname" > < em > s< / em > < / span > , < / td >
2019-06-22 10:30:09 -07:00
< / tr >
< tr >
< td class = "paramkey" > < / td >
< td > < / td >
2024-06-04 14:37:16 -07:00
< td class = "paramtype" > size_t< / td > < td class = "paramname" > < span class = "paramname" > < em > n< / em > < / span >   )< / td >
2019-06-22 10:30:09 -07:00
< / tr >
< / table >
< / div > < div class = "memdoc" >
2025-01-03 17:56:15 -08:00
< p > Allocate and duplicate a string up to < em class = "arg" > n< / em > bytes. < / p >
2019-06-22 10:30:09 -07:00
< dl class = "params" > < dt > Parameters< / dt > < dd >
< table class = "params" >
2025-01-03 17:56:15 -08:00
< tr > < td class = "paramname" > s< / td > < td > string to duplicate (or < em class = "arg" > NULL< / em > ). < / td > < / tr >
2019-06-22 10:30:09 -07:00
< tr > < td class = "paramname" > n< / td > < td > maximum number of bytes to copy (excluding the terminating zero). < / td > < / tr >
< / table >
< / dd >
< / dl >
2025-01-03 17:56:15 -08:00
< dl class = "section return" > < dt > Returns< / dt > < dd > a pointer to newly allocated memory initialized to string < em class = "arg" > s< / em > up to the first < em class = "arg" > n< / em > bytes (and always zero terminated), or < em class = "arg" > NULL< / em > if either out of memory or if < em class = "arg" > s< / em > is < em class = "arg" > NULL< / em > .< / dd > < / dl >
2024-06-04 14:37:16 -07:00
< 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 >
2019-06-22 10:30:09 -07:00
< / div >
< / div >
2024-06-04 14:37:16 -07:00
< a id = "gae6e38c4403247a7b40d80419e093bfb8" name = "gae6e38c4403247a7b40d80419e093bfb8" > < / a >
< h2 class = "memtitle" > < span class = "permalink" > < a href = "#gae6e38c4403247a7b40d80419e093bfb8" > ◆   < / a > < / span > mi_zalloc()< / h2 >
2019-06-22 10:30:09 -07:00
< div class = "memitem" >
< div class = "memproto" >
< table class = "memname" >
< tr >
2024-06-04 14:37:16 -07:00
< td class = "memname" > void * mi_zalloc < / td >
2019-06-22 10:30:09 -07:00
< td > (< / td >
2024-06-04 14:37:16 -07:00
< td class = "paramtype" > size_t< / td > < td class = "paramname" > < span class = "paramname" > < em > size< / em > < / span > < / td > < td > )< / td >
2019-06-22 10:30:09 -07:00
< 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 >
2025-01-03 17:56:15 -08:00
< dl class = "section return" > < dt > Returns< / dt > < dd > Pointer to newly allocated zero initialized memory, or < em class = "arg" > NULL< / em > if out of memory. < / dd > < / dl >
2019-06-22 10:30:09 -07:00
< / div >
< / div >
< / div > <!-- contents -->
< / div > <!-- doc - content -->
<!-- start footer part -->
< div id = "nav-path" class = "navpath" > <!-- id is needed for treeview function! -->
< ul >
2025-01-03 17:56:15 -08:00
< 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.13.1 < / li >
2019-06-22 10:30:09 -07:00
< / ul >
< / div >
< / body >
< / html >