<!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.18.0"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>mi-malloc: Extended Functions</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="codefolding.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="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>
<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"> 3.6/2.5/1.15</span>
</div>
</td>
<td> <div id="MSearchBox" class="MSearchBoxInactive">
<span class="left">
<span id="MSearchSelect" class="search-icon"><span class="search-icon-dropdown"></span></span>
<input type="text" id="MSearchField" value="" placeholder="Search" accesskey="S"/>
</span><span class="right">
<a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><div id="MSearchCloseImg" class="close-icon"></div></a>
</span>
</div>
</td>
</tr>
</tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.18.0 -->
<script type="text/javascript">
let searchBox = new SearchBox("searchBox", "search/",'.html');
</script>
<script type="text/javascript">
document.addEventListener('DOMContentLoaded', codefold.init);
</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" class="ui-resizable-handle">
</div>
</div>
<script type="text/javascript">
document.addEventListener('DOMContentLoaded',() => { initNavTree('group__extended.html','',''); });
</script>
<div id="container">
<div id="doc-content">
<!-- window showing the filter options -->
<div id="MSearchSelectWindow">
</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="headertitle"><div class="title">Extended Functions </div></div>
</div><!--header-->
<div class="contents">
<p>Internal functionality.
<a href="#details">More...</a></p>
<table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 id="header-define-members" class="groupheader"><a id="define-members" name="define-members"></a>
Macros</h2></td></tr>
<tr class="memitem:ga070c011175b3a1de57a481966a57b8ba" id="r_ga070c011175b3a1de57a481966a57b8ba"><td class="memItemLeft">#define </td><td class="memItemRight"><a class="el" href="#ga070c011175b3a1de57a481966a57b8ba">MI_SMALL_WSIZE_MAX</a></td></tr>
<tr class="memdesc:ga070c011175b3a1de57a481966a57b8ba"><td class="mdescLeft"> </td><td class="mdescRight">Maximum number of machine words allowed for <a class="el" href="#gaddce8f584e649a1b7ca48298dc52fe77" title="v3: Allocate a small object with its size expressed in machine words.">mi_wmalloc_small()</a>. <br /></td></tr>
<tr class="memitem:ga1ea64283508718d9d645c38efc2f4305" id="r_ga1ea64283508718d9d645c38efc2f4305"><td class="memItemLeft">#define </td><td class="memItemRight"><a class="el" href="#ga1ea64283508718d9d645c38efc2f4305">MI_SMALL_SIZE_MAX</a></td></tr>
<tr class="memdesc:ga1ea64283508718d9d645c38efc2f4305"><td class="mdescLeft"> </td><td class="mdescRight">Maximum size in bytes allowed for small allocations in <a class="el" href="#ga7f050bc6b897da82692174f5fce59cde" title="Allocate a small object.">mi_malloc_small</a>, <a class="el" href="#ga51c47637e81df0e2f13a2d7a2dec123e" title="Allocate a zero initialized small object.">mi_zalloc_small</a>, <a class="el" href="group__heap.html#ga012c5c8abe22b10043de39ff95909541" title="Allocate a small object in a specific heap.">mi_heap_malloc_small</a>, <a class="el" href="group__heap.html#ga0994f44cc595f9c1840a9af162d98597" title="Allocate a small object in a specific heap.">mi_heap_zalloc_small</a>, <a class="el" href="group__theap.html#ga1fc65302a212daaecb21abda96ff247c" title="Allocate a small object in a specific theap.">mi_theap_malloc_small</a>, and <a class="el" href="group__theap.html#gaa85fccf9d40af3e826c5932aded1d534" title="Allocate a small object in a specific theap.">mi_theap_zalloc_small</a> (<span class="tt">128*sizeof(size_t)</span>, or 1 KiB on 64-bit systems). <br /></td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 id="header-typedef-members" class="groupheader"><a id="typedef-members" name="typedef-members"></a>
Typedefs</h2></td></tr>
<tr class="memitem:ga292a45f7dbc7cd23c5352ce1f0002816" id="r_ga292a45f7dbc7cd23c5352ce1f0002816"><td class="memItemLeft">typedef void </td><td class="memItemRight"><a class="el" href="#ga292a45f7dbc7cd23c5352ce1f0002816">mi_deferred_free_fun</a>(bool force, unsigned long long heartbeat, void *arg)</td></tr>
<tr class="memdesc:ga292a45f7dbc7cd23c5352ce1f0002816"><td class="mdescLeft"> </td><td class="mdescRight">Type of deferred free functions. <br /></td></tr>
<tr class="memitem:gadf31cea7d0332a81c8b882cbbdbadb8d" id="r_gadf31cea7d0332a81c8b882cbbdbadb8d"><td class="memItemLeft">typedef void </td><td class="memItemRight"><a class="el" href="#gadf31cea7d0332a81c8b882cbbdbadb8d">mi_output_fun</a>(const char *msg, void *arg)</td></tr>
<tr class="memdesc:gadf31cea7d0332a81c8b882cbbdbadb8d"><td class="mdescLeft"> </td><td class="mdescRight">Type of output functions. <br /></td></tr>
<tr class="memitem:ga83fc6a688b322261e1c2deab000b0591" id="r_ga83fc6a688b322261e1c2deab000b0591"><td class="memItemLeft">typedef void </td><td class="memItemRight"><a class="el" href="#ga83fc6a688b322261e1c2deab000b0591">mi_error_fun</a>(int err, void *arg)</td></tr>
<tr class="memdesc:ga83fc6a688b322261e1c2deab000b0591"><td class="mdescLeft"> </td><td class="mdescRight">Type of error callback functions. <br /></td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 id="header-func-members" class="groupheader"><a id="func-members" name="func-members"></a>
Functions</h2></td></tr>
<tr class="memitem:gae9ddddcf14a58d0224ef3c8778e5b057" id="r_gae9ddddcf14a58d0224ef3c8778e5b057"><td class="memItemLeft">int </td><td class="memItemRight"><a class="el" href="#gae9ddddcf14a58d0224ef3c8778e5b057">mi_version</a> (void)</td></tr>
<tr class="memdesc:gae9ddddcf14a58d0224ef3c8778e5b057"><td class="mdescLeft"> </td><td class="mdescRight">Return the mimalloc version. <br /></td></tr>
<tr class="memitem:ga421430e2226d7d468529cec457396756" id="r_ga421430e2226d7d468529cec457396756"><td class="memItemLeft">void </td><td class="memItemRight"><a class="el" href="#ga421430e2226d7d468529cec457396756">mi_collect</a> (bool force)</td></tr>
<tr class="memdesc:ga421430e2226d7d468529cec457396756"><td class="mdescLeft"> </td><td class="mdescRight">Eagerly free memory. <br /></td></tr>
<tr class="memitem:ga0c900eb3ce2344ee9cbaa49b2668bcca" id="r_ga0c900eb3ce2344ee9cbaa49b2668bcca"><td class="memItemLeft">void </td><td class="memItemRight"><a class="el" href="#ga0c900eb3ce2344ee9cbaa49b2668bcca">mi_collect_reduce</a> (size_t target_thread_owned)</td></tr>
<tr class="memitem:ga33e54ec86fc7da4bebb673429c399402" id="r_ga33e54ec86fc7da4bebb673429c399402"><td class="memItemLeft">void </td><td class="memItemRight"><a class="el" href="#ga33e54ec86fc7da4bebb673429c399402">mi_process_init</a> (void)</td></tr>
<tr class="memdesc:ga33e54ec86fc7da4bebb673429c399402"><td class="mdescLeft"> </td><td class="mdescRight">Initialize mimalloc for the process. Normally called automatically; repeated calls have no effect. <br /></td></tr>
<tr class="memitem:ga4adb0ce31957ca422d62d248fab9f7cf" id="r_ga4adb0ce31957ca422d62d248fab9f7cf"><td class="memItemLeft">void </td><td class="memItemRight"><a class="el" href="#ga4adb0ce31957ca422d62d248fab9f7cf">mi_process_done</a> (void)</td></tr>
<tr class="memdesc:ga4adb0ce31957ca422d62d248fab9f7cf"><td class="mdescLeft"> </td><td class="mdescRight">Perform process-exit cleanup. <br /></td></tr>
<tr class="memitem:gada899104276aac52539eb4de7c020f1f" id="r_gada899104276aac52539eb4de7c020f1f"><td class="memItemLeft">void </td><td class="memItemRight"><a class="el" href="#gada899104276aac52539eb4de7c020f1f">mi_thread_set_in_threadpool</a> (void)</td></tr>
<tr class="memdesc:gada899104276aac52539eb4de7c020f1f"><td class="mdescLeft"> </td><td class="mdescRight"><b>v3</b>: Communicate that a thread is in a threadpool. <br /></td></tr>
<tr class="memitem:gaad25050b19f30cd79397b227e0157a3f" id="r_gaad25050b19f30cd79397b227e0157a3f"><td class="memItemLeft">bool </td><td class="memItemRight"><a class="el" href="#gaad25050b19f30cd79397b227e0157a3f">mi_is_redirected</a> ()</td></tr>
<tr class="memdesc:gaad25050b19f30cd79397b227e0157a3f"><td class="mdescLeft"> </td><td class="mdescRight">Is the C runtime <em class="arg">malloc</em> API redirected? <br /></td></tr>
<tr class="memitem:gaf8e73efc2cbca9ebfdfb166983a04c17" id="r_gaf8e73efc2cbca9ebfdfb166983a04c17"><td class="memItemLeft">void </td><td class="memItemRight"><a class="el" href="#gaf8e73efc2cbca9ebfdfb166983a04c17">mi_thread_init</a> (void)</td></tr>
<tr class="memdesc:gaf8e73efc2cbca9ebfdfb166983a04c17"><td class="mdescLeft"> </td><td class="mdescRight">Initialize mimalloc on a thread. <br /></td></tr>
<tr class="memitem:ga0ae4581e85453456a0d658b2b98bf7bf" id="r_ga0ae4581e85453456a0d658b2b98bf7bf"><td class="memItemLeft">void </td><td class="memItemRight"><a class="el" href="#ga0ae4581e85453456a0d658b2b98bf7bf">mi_thread_done</a> (void)</td></tr>
<tr class="memdesc:ga0ae4581e85453456a0d658b2b98bf7bf"><td class="mdescLeft"> </td><td class="mdescRight">Uninitialize mimalloc on a thread. <br /></td></tr>
<tr class="memitem:ga3460a6ca91af97be4058f523d3cb8ece" id="r_ga3460a6ca91af97be4058f523d3cb8ece"><td class="memItemLeft">void </td><td class="memItemRight"><a class="el" href="#ga3460a6ca91af97be4058f523d3cb8ece">mi_register_deferred_free</a> (<a class="el" href="#ga292a45f7dbc7cd23c5352ce1f0002816">mi_deferred_free_fun</a> *deferred_free, void *arg)</td></tr>
<tr class="memdesc:ga3460a6ca91af97be4058f523d3cb8ece"><td class="mdescLeft"> </td><td class="mdescRight">Register a deferred free function. <br /></td></tr>
<tr class="memitem:gae5b17ff027cd2150b43a33040250cf3f" id="r_gae5b17ff027cd2150b43a33040250cf3f"><td class="memItemLeft">void </td><td class="memItemRight"><a class="el" href="#gae5b17ff027cd2150b43a33040250cf3f">mi_register_output</a> (<a class="el" href="#gadf31cea7d0332a81c8b882cbbdbadb8d">mi_output_fun</a> *out, void *arg)</td></tr>
<tr class="memdesc:gae5b17ff027cd2150b43a33040250cf3f"><td class="mdescLeft"> </td><td class="mdescRight">Register an output function. <br /></td></tr>
<tr class="memitem:gaa1d55e0e894be240827e5d87ec3a1f45" id="r_gaa1d55e0e894be240827e5d87ec3a1f45"><td class="memItemLeft">void </td><td class="memItemRight"><a class="el" href="#gaa1d55e0e894be240827e5d87ec3a1f45">mi_register_error</a> (<a class="el" href="#ga83fc6a688b322261e1c2deab000b0591">mi_error_fun</a> *errfun, void *arg)</td></tr>
<tr class="memdesc:gaa1d55e0e894be240827e5d87ec3a1f45"><td class="mdescLeft"> </td><td class="mdescRight">Register an error callback function. <br /></td></tr>
<tr class="memitem:ga7f050bc6b897da82692174f5fce59cde" id="r_ga7f050bc6b897da82692174f5fce59cde"><td class="memItemLeft">void * </td><td class="memItemRight"><a class="el" href="#ga7f050bc6b897da82692174f5fce59cde">mi_malloc_small</a> (size_t size)</td></tr>
<tr class="memdesc:ga7f050bc6b897da82692174f5fce59cde"><td class="mdescLeft"> </td><td class="mdescRight">Allocate a small object. <br /></td></tr>
<tr class="memitem:gaddce8f584e649a1b7ca48298dc52fe77" id="r_gaddce8f584e649a1b7ca48298dc52fe77"><td class="memItemLeft">void * </td><td class="memItemRight"><a class="el" href="#gaddce8f584e649a1b7ca48298dc52fe77">mi_wmalloc_small</a> (size_t wsize)</td></tr>
<tr class="memdesc:gaddce8f584e649a1b7ca48298dc52fe77"><td class="mdescLeft"> </td><td class="mdescRight"><b>v3</b>: Allocate a small object with its size expressed in machine words. <br /></td></tr>
<tr class="memitem:ga61113cc91b1d6de4ace7b693739b2352" id="r_ga61113cc91b1d6de4ace7b693739b2352"><td class="memItemLeft">void * </td><td class="memItemRight"><a class="el" href="#ga61113cc91b1d6de4ace7b693739b2352">mi_wzalloc_small</a> (size_t wsize)</td></tr>
<tr class="memdesc:ga61113cc91b1d6de4ace7b693739b2352"><td class="mdescLeft"> </td><td class="mdescRight"><b>v3</b>: As <a class="el" href="#gaddce8f584e649a1b7ca48298dc52fe77" title="v3: Allocate a small object with its size expressed in machine words.">mi_wmalloc_small()</a>, but zero-initialize the allocation. <br /></td></tr>
<tr class="memitem:ga4bed1e708005f676c2cc5f5627f3290a" id="r_ga4bed1e708005f676c2cc5f5627f3290a"><td class="memItemLeft">size_t </td><td class="memItemRight"><a class="el" href="#ga4bed1e708005f676c2cc5f5627f3290a">mi_wsize_from_size</a> (size_t size)</td></tr>
<tr class="memdesc:ga4bed1e708005f676c2cc5f5627f3290a"><td class="mdescLeft"> </td><td class="mdescRight"><b>v3</b>: Convert a byte size to a number of <span class="tt">sizeof(size_t)</span> words, rounding up. <br /></td></tr>
<tr class="memitem:ga51c47637e81df0e2f13a2d7a2dec123e" id="r_ga51c47637e81df0e2f13a2d7a2dec123e"><td class="memItemLeft">void * </td><td class="memItemRight"><a class="el" href="#ga51c47637e81df0e2f13a2d7a2dec123e">mi_zalloc_small</a> (size_t size)</td></tr>
<tr class="memdesc:ga51c47637e81df0e2f13a2d7a2dec123e"><td class="mdescLeft"> </td><td class="mdescRight">Allocate a zero initialized small object. <br /></td></tr>
<tr class="memitem:ga2a8469764c38dcaf878f36e5f50e3610" id="r_ga2a8469764c38dcaf878f36e5f50e3610"><td class="memItemLeft">void </td><td class="memItemRight"><a class="el" href="#ga2a8469764c38dcaf878f36e5f50e3610">mi_free_small</a> (void *p)</td></tr>
<tr class="memdesc:ga2a8469764c38dcaf878f36e5f50e3610"><td class="mdescLeft"> </td><td class="mdescRight"><b>v3</b>: Can be used to free an object that was allocated with <a class="el" href="#ga7f050bc6b897da82692174f5fce59cde" title="Allocate a small object.">mi_malloc_small()</a> or any allocation with a size < <a class="el" href="#ga1ea64283508718d9d645c38efc2f4305" title="Maximum size in bytes allowed for small allocations in mi_malloc_small, mi_zalloc_small,...">MI_SMALL_SIZE_MAX()</a> <br /></td></tr>
<tr class="memitem:ga22890f54e5be433837069c8e97fdf379" id="r_ga22890f54e5be433837069c8e97fdf379"><td class="memItemLeft">void </td><td class="memItemRight"><a class="el" href="#ga22890f54e5be433837069c8e97fdf379">mi_free_small_nonnull</a> (void *p)</td></tr>
<tr class="memdesc:ga22890f54e5be433837069c8e97fdf379"><td class="mdescLeft"> </td><td class="mdescRight"><b>v3</b>: Can be used to free an object that was allocated with <a class="el" href="#ga7f050bc6b897da82692174f5fce59cde" title="Allocate a small object.">mi_malloc_small()</a> or any allocation with a size < <a class="el" href="#ga1ea64283508718d9d645c38efc2f4305" title="Maximum size in bytes allowed for small allocations in mi_malloc_small, mi_zalloc_small,...">MI_SMALL_SIZE_MAX()</a> <br /></td></tr>
<tr class="memitem:gaca0c3f3a03a9d5e4869e8b7cb519f209" id="r_gaca0c3f3a03a9d5e4869e8b7cb519f209"><td class="memItemLeft">void </td><td class="memItemRight"><a class="el" href="#gaca0c3f3a03a9d5e4869e8b7cb519f209">mi_free_small_local</a> (void *p)</td></tr>
<tr class="memdesc:gaca0c3f3a03a9d5e4869e8b7cb519f209"><td class="mdescLeft"> </td><td class="mdescRight"><b>v3</b>: As <a class="el" href="#ga2a8469764c38dcaf878f36e5f50e3610" title="v3: Can be used to free an object that was allocated with mi_malloc_small() or any allocation with a ...">mi_free_small()</a>, but the block's page must be owned by the calling thread. <br /></td></tr>
<tr class="memitem:gae87594f2195ccde8fd3fe30038bc7cd5" id="r_gae87594f2195ccde8fd3fe30038bc7cd5"><td class="memItemLeft">void </td><td class="memItemRight"><a class="el" href="#gae87594f2195ccde8fd3fe30038bc7cd5">mi_free_small_local_nonnull</a> (void *p)</td></tr>
<tr class="memdesc:gae87594f2195ccde8fd3fe30038bc7cd5"><td class="mdescLeft"> </td><td class="mdescRight">As <a class="el" href="#gaca0c3f3a03a9d5e4869e8b7cb519f209" title="v3: As mi_free_small(), but the block's page must be owned by the calling thread.">mi_free_small_local()</a>, but <em class="arg">p</em> must not be <em class="arg">NULL</em>. <br /></td></tr>
</table>
<a name="details" id="details"></a><h2 id="header-details" class="groupheader">Detailed Description</h2>
<div class="textblock"><p>Internal functionality. </p>
</div><a name="doc-define-members" id="doc-define-members"></a><h2 id="header-doc-define-members" class="groupheader">Macro Definition Documentation</h2>
<a id="ga1ea64283508718d9d645c38efc2f4305" name="ga1ea64283508718d9d645c38efc2f4305"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga1ea64283508718d9d645c38efc2f4305">◆ </a></span>MI_SMALL_SIZE_MAX</h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">#define MI_SMALL_SIZE_MAX</td>
</tr>
</table>
</div><div class="memdoc">
<p>Maximum size in bytes allowed for small allocations in <a class="el" href="#ga7f050bc6b897da82692174f5fce59cde" title="Allocate a small object.">mi_malloc_small</a>, <a class="el" href="#ga51c47637e81df0e2f13a2d7a2dec123e" title="Allocate a zero initialized small object.">mi_zalloc_small</a>, <a class="el" href="group__heap.html#ga012c5c8abe22b10043de39ff95909541" title="Allocate a small object in a specific heap.">mi_heap_malloc_small</a>, <a class="el" href="group__heap.html#ga0994f44cc595f9c1840a9af162d98597" title="Allocate a small object in a specific heap.">mi_heap_zalloc_small</a>, <a class="el" href="group__theap.html#ga1fc65302a212daaecb21abda96ff247c" title="Allocate a small object in a specific theap.">mi_theap_malloc_small</a>, and <a class="el" href="group__theap.html#gaa85fccf9d40af3e826c5932aded1d534" title="Allocate a small object in a specific theap.">mi_theap_zalloc_small</a> (<span class="tt">128*sizeof(size_t)</span>, or 1 KiB on 64-bit systems). </p>
</div>
</div>
<a id="ga070c011175b3a1de57a481966a57b8ba" name="ga070c011175b3a1de57a481966a57b8ba"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga070c011175b3a1de57a481966a57b8ba">◆ </a></span>MI_SMALL_WSIZE_MAX</h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">#define MI_SMALL_WSIZE_MAX</td>
</tr>
</table>
</div><div class="memdoc">
<p>Maximum number of machine words allowed for <a class="el" href="#gaddce8f584e649a1b7ca48298dc52fe77" title="v3: Allocate a small object with its size expressed in machine words.">mi_wmalloc_small()</a>. </p>
<p>A machine word is <span class="tt">sizeof(size_t)</span> bytes. </p>
</div>
</div>
<a name="doc-typedef-members" id="doc-typedef-members"></a><h2 id="header-doc-typedef-members" class="groupheader">Typedef Documentation</h2>
<a id="ga292a45f7dbc7cd23c5352ce1f0002816" name="ga292a45f7dbc7cd23c5352ce1f0002816"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga292a45f7dbc7cd23c5352ce1f0002816">◆ </a></span>mi_deferred_free_fun</h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">typedef void mi_deferred_free_fun(bool force, unsigned long long heartbeat, void *arg)</td>
</tr>
</table>
</div><div class="memdoc">
<p>Type of deferred free functions. </p>
<dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramname">force</td><td>If <em class="arg">true</em> all outstanding items should be freed. </td></tr>
<tr><td class="paramname">heartbeat</td><td>A monotonically increasing count. </td></tr>
<tr><td class="paramname">arg</td><td>Argument that was passed at registration to hold extra state.</td></tr>
</table>
</dd>
</dl>
<dl class="section see"><dt>See also</dt><dd><a class="el" href="#ga3460a6ca91af97be4058f523d3cb8ece" title="Register a deferred free function.">mi_register_deferred_free</a> </dd></dl>
</div>
</div>
<a id="ga83fc6a688b322261e1c2deab000b0591" name="ga83fc6a688b322261e1c2deab000b0591"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga83fc6a688b322261e1c2deab000b0591">◆ </a></span>mi_error_fun</h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">typedef void mi_error_fun(int err, void *arg)</td>
</tr>
</table>
</div><div class="memdoc">
<p>Type of error callback functions. </p>
<dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramname">err</td><td>Error code (see <a class="el" href="#gaa1d55e0e894be240827e5d87ec3a1f45" title="Register an error callback function.">mi_register_error()</a> for a complete list). </td></tr>
<tr><td class="paramname">arg</td><td>Argument that was passed at registration to hold extra state.</td></tr>
</table>
</dd>
</dl>
<dl class="section see"><dt>See also</dt><dd><a class="el" href="#gaa1d55e0e894be240827e5d87ec3a1f45" title="Register an error callback function.">mi_register_error()</a> </dd></dl>
</div>
</div>
<a id="gadf31cea7d0332a81c8b882cbbdbadb8d" name="gadf31cea7d0332a81c8b882cbbdbadb8d"></a>
<h2 class="memtitle"><span class="permalink"><a href="#gadf31cea7d0332a81c8b882cbbdbadb8d">◆ </a></span>mi_output_fun</h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">typedef void mi_output_fun(const char *msg, void *arg)</td>
</tr>
</table>
</div><div class="memdoc">
<p>Type of output functions. </p>
<dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramname">msg</td><td>Message to output. </td></tr>
<tr><td class="paramname">arg</td><td>Argument that was passed at registration to hold extra state.</td></tr>
</table>
</dd>
</dl>
<dl class="section see"><dt>See also</dt><dd><a class="el" href="#gae5b17ff027cd2150b43a33040250cf3f" title="Register an output function.">mi_register_output()</a> </dd></dl>
</div>
</div>
<a name="doc-func-members" id="doc-func-members"></a><h2 id="header-doc-func-members" class="groupheader">Function Documentation</h2>
<a id="ga421430e2226d7d468529cec457396756" name="ga421430e2226d7d468529cec457396756"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga421430e2226d7d468529cec457396756">◆ </a></span>mi_collect()</h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void mi_collect </td>
<td>(</td>
<td class="paramtype">bool</td> <td class="paramname"><span class="paramname"><em>force</em></span></td><td>)</td>
<td></td>
</tr>
</table>
</div><div class="memdoc">
<p>Eagerly free memory. </p>
<dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramname">force</td><td>If <em class="arg">true</em>, aggressively return memory to the OS (can be expensive!)</td></tr>
</table>
</dd>
</dl>
<p>Regular code should not have to call this function. It can be beneficial in very narrow circumstances; in particular, when a long running thread allocates a lot of blocks that are freed by other threads it may improve resource usage by calling this every once in a while. </p>
</div>
</div>
<a id="ga0c900eb3ce2344ee9cbaa49b2668bcca" name="ga0c900eb3ce2344ee9cbaa49b2668bcca"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga0c900eb3ce2344ee9cbaa49b2668bcca">◆ </a></span>mi_collect_reduce()</h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void mi_collect_reduce </td>
<td>(</td>
<td class="paramtype">size_t</td> <td class="paramname"><span class="paramname"><em>target_thread_owned</em></span></td><td>)</td>
<td></td>
</tr>
</table>
</div><div class="memdoc">
<dl class="deprecated"><dt><b><a class="el" href="deprecated.html#_deprecated000004">Deprecated</a></b></dt><dd>Historical collection API, declared but not implemented in <b>v3</b>. Use <a class="el" href="#ga421430e2226d7d468529cec457396756" title="Eagerly free memory.">mi_collect()</a> instead. </dd></dl>
</div>
</div>
<a id="ga2a8469764c38dcaf878f36e5f50e3610" name="ga2a8469764c38dcaf878f36e5f50e3610"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga2a8469764c38dcaf878f36e5f50e3610">◆ </a></span>mi_free_small()</h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void mi_free_small </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><b>v3</b>: Can be used to free an object that was allocated with <a class="el" href="#ga7f050bc6b897da82692174f5fce59cde" title="Allocate a small object.">mi_malloc_small()</a> or any allocation with a size < <a class="el" href="#ga1ea64283508718d9d645c38efc2f4305" title="Maximum size in bytes allowed for small allocations in mi_malloc_small, mi_zalloc_small,...">MI_SMALL_SIZE_MAX()</a> </p>
<dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramname">p</td><td>Pointer that was returned from <a class="el" href="#ga7f050bc6b897da82692174f5fce59cde" title="Allocate a small object.">mi_malloc_small</a> et al. (or <em class="arg">NULL</em> )</td></tr>
</table>
</dd>
</dl>
<p>This function is meant for use in run-time systems for best performance and does not check if the pointer was <em>indeed</em> allocated as a small object – use with care!</p>
<dl class="section see"><dt>See also</dt><dd><a class="el" href="#ga22890f54e5be433837069c8e97fdf379" title="v3: Can be used to free an object that was allocated with mi_malloc_small() or any allocation with a ...">mi_free_small_nonnull()</a> </dd>
<dd>
<a class="el" href="#ga7f050bc6b897da82692174f5fce59cde" title="Allocate a small object.">mi_malloc_small()</a> </dd>
<dd>
<a class="el" href="#ga51c47637e81df0e2f13a2d7a2dec123e" title="Allocate a zero initialized small object.">mi_zalloc_small()</a> </dd>
<dd>
<a class="el" href="group__heap.html#ga012c5c8abe22b10043de39ff95909541" title="Allocate a small object in a specific heap.">mi_heap_malloc_small()</a> </dd>
<dd>
<a class="el" href="group__heap.html#ga0994f44cc595f9c1840a9af162d98597" title="Allocate a small object in a specific heap.">mi_heap_zalloc_small()</a> </dd>
<dd>
<a class="el" href="group__theap.html#ga1fc65302a212daaecb21abda96ff247c" title="Allocate a small object in a specific theap.">mi_theap_malloc_small()</a> </dd>
<dd>
<a class="el" href="group__theap.html#gaa85fccf9d40af3e826c5932aded1d534" title="Allocate a small object in a specific theap.">mi_theap_zalloc_small()</a> </dd></dl>
</div>
</div>
<a id="gaca0c3f3a03a9d5e4869e8b7cb519f209" name="gaca0c3f3a03a9d5e4869e8b7cb519f209"></a>
<h2 class="memtitle"><span class="permalink"><a href="#gaca0c3f3a03a9d5e4869e8b7cb519f209">◆ </a></span>mi_free_small_local()</h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void mi_free_small_local </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><b>v3</b>: As <a class="el" href="#ga2a8469764c38dcaf878f36e5f50e3610" title="v3: Can be used to free an object that was allocated with mi_malloc_small() or any allocation with a ...">mi_free_small()</a>, but the block's page must be owned by the calling thread. </p>
<p><em class="arg">p</em> may be <em class="arg">NULL</em>. The caller must guarantee both the small size and page ownership. </p>
</div>
</div>
<a id="gae87594f2195ccde8fd3fe30038bc7cd5" name="gae87594f2195ccde8fd3fe30038bc7cd5"></a>
<h2 class="memtitle"><span class="permalink"><a href="#gae87594f2195ccde8fd3fe30038bc7cd5">◆ </a></span>mi_free_small_local_nonnull()</h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void mi_free_small_local_nonnull </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>As <a class="el" href="#gaca0c3f3a03a9d5e4869e8b7cb519f209" title="v3: As mi_free_small(), but the block's page must be owned by the calling thread.">mi_free_small_local()</a>, but <em class="arg">p</em> must not be <em class="arg">NULL</em>. </p>
</div>
</div>
<a id="ga22890f54e5be433837069c8e97fdf379" name="ga22890f54e5be433837069c8e97fdf379"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga22890f54e5be433837069c8e97fdf379">◆ </a></span>mi_free_small_nonnull()</h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void mi_free_small_nonnull </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><b>v3</b>: Can be used to free an object that was allocated with <a class="el" href="#ga7f050bc6b897da82692174f5fce59cde" title="Allocate a small object.">mi_malloc_small()</a> or any allocation with a size < <a class="el" href="#ga1ea64283508718d9d645c38efc2f4305" title="Maximum size in bytes allowed for small allocations in mi_malloc_small, mi_zalloc_small,...">MI_SMALL_SIZE_MAX()</a> </p>
<dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramname">p</td><td>Pointer that was returned from <a class="el" href="#ga7f050bc6b897da82692174f5fce59cde" title="Allocate a small object.">mi_malloc_small</a> et al. Cannot be <em class="arg">NULL</em> !</td></tr>
</table>
</dd>
</dl>
<p>This function is meant for use in run-time systems for best performance and does not check if the pointer was <em>indeed</em> allocated as a small object or not NULL – use with care!</p>
<dl class="section see"><dt>See also</dt><dd><a class="el" href="#ga2a8469764c38dcaf878f36e5f50e3610" title="v3: Can be used to free an object that was allocated with mi_malloc_small() or any allocation with a ...">mi_free_small()</a> </dd>
<dd>
<a class="el" href="#ga7f050bc6b897da82692174f5fce59cde" title="Allocate a small object.">mi_malloc_small()</a> </dd>
<dd>
<a class="el" href="#ga51c47637e81df0e2f13a2d7a2dec123e" title="Allocate a zero initialized small object.">mi_zalloc_small()</a> </dd>
<dd>
<a class="el" href="group__heap.html#ga012c5c8abe22b10043de39ff95909541" title="Allocate a small object in a specific heap.">mi_heap_malloc_small()</a> </dd>
<dd>
<a class="el" href="group__heap.html#ga0994f44cc595f9c1840a9af162d98597" title="Allocate a small object in a specific heap.">mi_heap_zalloc_small()</a> </dd>
<dd>
<a class="el" href="group__theap.html#ga1fc65302a212daaecb21abda96ff247c" title="Allocate a small object in a specific theap.">mi_theap_malloc_small()</a> </dd>
<dd>
<a class="el" href="group__theap.html#gaa85fccf9d40af3e826c5932aded1d534" title="Allocate a small object in a specific theap.">mi_theap_zalloc_small()</a> </dd></dl>
</div>
</div>
<a id="gaad25050b19f30cd79397b227e0157a3f" name="gaad25050b19f30cd79397b227e0157a3f"></a>
<h2 class="memtitle"><span class="permalink"><a href="#gaad25050b19f30cd79397b227e0157a3f">◆ </a></span>mi_is_redirected()</h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">bool mi_is_redirected </td>
<td>(</td>
<td class="paramname"><span class="paramname"><em></em></span></td><td>)</td>
<td></td>
</tr>
</table>
</div><div class="memdoc">
<p>Is the C runtime <em class="arg">malloc</em> API redirected? </p>
<dl class="section return"><dt>Returns</dt><dd><em class="arg">true</em> if all malloc API calls are redirected to mimalloc.</dd></dl>
<p>Currently only used on Windows. </p>
</div>
</div>
<a id="ga7f050bc6b897da82692174f5fce59cde" name="ga7f050bc6b897da82692174f5fce59cde"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga7f050bc6b897da82692174f5fce59cde">◆ </a></span>mi_malloc_small()</h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void * mi_malloc_small </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 a small object. </p>
<dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramname">size</td><td>The size in bytes, can be at most <a class="el" href="#ga1ea64283508718d9d645c38efc2f4305" title="Maximum size in bytes allowed for small allocations in mi_malloc_small, mi_zalloc_small,...">MI_SMALL_SIZE_MAX</a>. </td></tr>
</table>
</dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>a pointer to newly allocated memory of at least <em class="arg">size</em> bytes, or <em class="arg">NULL</em> if out of memory. This function is meant for use in run-time systems for best performance and does not check if <em class="arg">size</em> was indeed small – use with care! </dd></dl>
</div>
</div>
<a id="ga4adb0ce31957ca422d62d248fab9f7cf" name="ga4adb0ce31957ca422d62d248fab9f7cf"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga4adb0ce31957ca422d62d248fab9f7cf">◆ </a></span>mi_process_done()</h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void mi_process_done </td>
<td>(</td>
<td class="paramtype">void</td> <td class="paramname"><span class="paramname"><em></em></span></td><td>)</td>
<td></td>
</tr>
</table>
</div><div class="memdoc">
<p>Perform process-exit cleanup. </p>
<p>Normally called automatically on process exit or library unload. Not intended for use while the program continues allocating. </p>
</div>
</div>
<a id="ga33e54ec86fc7da4bebb673429c399402" name="ga33e54ec86fc7da4bebb673429c399402"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga33e54ec86fc7da4bebb673429c399402">◆ </a></span>mi_process_init()</h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void mi_process_init </td>
<td>(</td>
<td class="paramtype">void</td> <td class="paramname"><span class="paramname"><em></em></span></td><td>)</td>
<td></td>
</tr>
</table>
</div><div class="memdoc">
<p>Initialize mimalloc for the process. Normally called automatically; repeated calls have no effect. </p>
</div>
</div>
<a id="ga3460a6ca91af97be4058f523d3cb8ece" name="ga3460a6ca91af97be4058f523d3cb8ece"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga3460a6ca91af97be4058f523d3cb8ece">◆ </a></span>mi_register_deferred_free()</h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void mi_register_deferred_free </td>
<td>(</td>
<td class="paramtype"><a class="el" href="#ga292a45f7dbc7cd23c5352ce1f0002816">mi_deferred_free_fun</a> *</td> <td class="paramname"><span class="paramname"><em>deferred_free</em></span>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">void *</td> <td class="paramname"><span class="paramname"><em>arg</em></span> )</td>
</tr>
</table>
</div><div class="memdoc">
<p>Register a deferred free function. </p>
<dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramname">deferred_free</td><td>Address of a deferred free-ing function or <em class="arg">NULL</em> to unregister. </td></tr>
<tr><td class="paramname">arg</td><td>Argument that will be passed on to the deferred free function.</td></tr>
</table>
</dd>
</dl>
<p>Some runtime systems use deferred free-ing, for example when using reference counting to limit the worst case free time. Such systems can register (re-entrant) deferred free function to free more memory on demand. When the <em class="arg">force</em> parameter is <em class="arg">true</em> all possible memory should be freed. The per-thread <em class="arg">heartbeat</em> parameter is monotonically increasing and guaranteed to be deterministic if the program allocates deterministically. The <em class="arg">deferred_free</em> function is guaranteed to be called deterministically after some number of allocations (regardless of freeing or available free memory). At most one <em class="arg">deferred_free</em> function can be active. </p>
</div>
</div>
<a id="gaa1d55e0e894be240827e5d87ec3a1f45" name="gaa1d55e0e894be240827e5d87ec3a1f45"></a>
<h2 class="memtitle"><span class="permalink"><a href="#gaa1d55e0e894be240827e5d87ec3a1f45">◆ </a></span>mi_register_error()</h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void mi_register_error </td>
<td>(</td>
<td class="paramtype"><a class="el" href="#ga83fc6a688b322261e1c2deab000b0591">mi_error_fun</a> *</td> <td class="paramname"><span class="paramname"><em>errfun</em></span>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">void *</td> <td class="paramname"><span class="paramname"><em>arg</em></span> )</td>
</tr>
</table>
</div><div class="memdoc">
<p>Register an error callback function. </p>
<dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramname">errfun</td><td>The error function that is called on an error (use <em class="arg">NULL</em> for default) </td></tr>
<tr><td class="paramname">arg</td><td>Extra argument that will be passed on to the error function.</td></tr>
</table>
</dd>
</dl>
<p>The <em class="arg">errfun</em> function is called on an error in mimalloc after emitting an error message (through the output function). It as always legal to just return from the <em class="arg">errfun</em> function in which case allocation functions generally return <em class="arg">NULL</em> or ignore the condition. An <em class="arg">EFAULT</em> error message is always shown, and when compiled in secure mode, mimalloc always calls abort() after an <em class="arg">EFAULT</em> error (even if the error function returns). The possible error codes are:</p><ul>
<li><em class="arg">EAGAIN:</em> Double free was detected (only in debug and secure mode).</li>
<li><em class="arg">EFAULT:</em> Corrupted free list or meta-data was detected (only in debug and secure mode).</li>
<li><em class="arg">ENOMEM:</em> Not enough memory available to satisfy the request.</li>
<li><em class="arg">EOVERFLOW:</em> Too large a request, for example in <a class="el" href="group__malloc.html#ga6686568014b54d1e6c7ac64a076e4f56" title="Allocate zero-initialized count elements of size bytes.">mi_calloc()</a>, the <em class="arg">count</em> and <em class="arg">size</em> parameters are too large.</li>
<li><em class="arg">EINVAL:</em> Trying to free or re-allocate an invalid pointer.</li>
</ul>
<p>Independent of the error code passed to <em class="arg">errfun</em>, allocation functions that return <em class="arg">NULL</em> set <em class="arg">errno</em> as required by POSIX: <em class="arg">ENOMEM</em>, or <em class="arg">EINVAL</em> for an invalid alignment. Other errors (like freeing an invalid pointer) do not modify <em class="arg">errno</em>. </p>
</div>
</div>
<a id="gae5b17ff027cd2150b43a33040250cf3f" name="gae5b17ff027cd2150b43a33040250cf3f"></a>
<h2 class="memtitle"><span class="permalink"><a href="#gae5b17ff027cd2150b43a33040250cf3f">◆ </a></span>mi_register_output()</h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void mi_register_output </td>
<td>(</td>
<td class="paramtype"><a class="el" href="#gadf31cea7d0332a81c8b882cbbdbadb8d">mi_output_fun</a> *</td> <td class="paramname"><span class="paramname"><em>out</em></span>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">void *</td> <td class="paramname"><span class="paramname"><em>arg</em></span> )</td>
</tr>
</table>
</div><div class="memdoc">
<p>Register an output function. </p>
<dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramname">out</td><td>The output function, use <span class="tt">NULL</span> to output to stderr. </td></tr>
<tr><td class="paramname">arg</td><td>Argument that will be passed on to the output function.</td></tr>
</table>
</dd>
</dl>
<p>The <span class="tt">out</span> function is called to output any information from mimalloc, like verbose or warning messages. </p>
</div>
</div>
<a id="ga0ae4581e85453456a0d658b2b98bf7bf" name="ga0ae4581e85453456a0d658b2b98bf7bf"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga0ae4581e85453456a0d658b2b98bf7bf">◆ </a></span>mi_thread_done()</h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void mi_thread_done </td>
<td>(</td>
<td class="paramtype">void</td> <td class="paramname"><span class="paramname"><em></em></span></td><td>)</td>
<td></td>
</tr>
</table>
</div><div class="memdoc">
<p>Uninitialize mimalloc on a thread. </p>
<p>Should not be used as on most systems (pthreads, windows) this is done automatically. Ensures that any memory that is not freed yet (but will be freed by other threads in the future) is properly handled. Afterwards, the thread is not implicitly re-initialized: allocations (for example in thread-local destructors) use a shared fallback heap until <a class="el" href="#gaf8e73efc2cbca9ebfdfb166983a04c17" title="Initialize mimalloc on a thread.">mi_thread_init()</a> is called explicitly. </p>
</div>
</div>
<a id="gaf8e73efc2cbca9ebfdfb166983a04c17" name="gaf8e73efc2cbca9ebfdfb166983a04c17"></a>
<h2 class="memtitle"><span class="permalink"><a href="#gaf8e73efc2cbca9ebfdfb166983a04c17">◆ </a></span>mi_thread_init()</h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void mi_thread_init </td>
<td>(</td>
<td class="paramtype">void</td> <td class="paramname"><span class="paramname"><em></em></span></td><td>)</td>
<td></td>
</tr>
</table>
</div><div class="memdoc">
<p>Initialize mimalloc on a thread. </p>
<p>Should not be used as on most systems (pthreads, windows) this is done automatically. </p>
</div>
</div>
<a id="gada899104276aac52539eb4de7c020f1f" name="gada899104276aac52539eb4de7c020f1f"></a>
<h2 class="memtitle"><span class="permalink"><a href="#gada899104276aac52539eb4de7c020f1f">◆ </a></span>mi_thread_set_in_threadpool()</h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void mi_thread_set_in_threadpool </td>
<td>(</td>
<td class="paramtype">void</td> <td class="paramname"><span class="paramname"><em></em></span></td><td>)</td>
<td></td>
</tr>
</table>
</div><div class="memdoc">
<p><b>v3</b>: Communicate that a thread is in a threadpool. </p>
<p>This is done automatically for threads in the Windows threadpool, but if using a custom threadpool it is good to call this on worker threads. Internally, mimalloc uses different locality heuristics for worker threads to try to reduce non-local accesss. </p>
</div>
</div>
<a id="gae9ddddcf14a58d0224ef3c8778e5b057" name="gae9ddddcf14a58d0224ef3c8778e5b057"></a>
<h2 class="memtitle"><span class="permalink"><a href="#gae9ddddcf14a58d0224ef3c8778e5b057">◆ </a></span>mi_version()</h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">int mi_version </td>
<td>(</td>
<td class="paramtype">void</td> <td class="paramname"><span class="paramname"><em></em></span></td><td>)</td>
<td></td>
</tr>
</table>
</div><div class="memdoc">
<p>Return the mimalloc version. </p>
<dl class="section return"><dt>Returns</dt><dd>The version. For v1,v2 the version is 100*major + 10*minor + patch (for example 227 for v2.2.7). For <b>v3</b>, it is 1000*major + 100*minor + path (for example, 3207 for v3.2.7). </dd></dl>
</div>
</div>
<a id="gaddce8f584e649a1b7ca48298dc52fe77" name="gaddce8f584e649a1b7ca48298dc52fe77"></a>
<h2 class="memtitle"><span class="permalink"><a href="#gaddce8f584e649a1b7ca48298dc52fe77">◆ </a></span>mi_wmalloc_small()</h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void * mi_wmalloc_small </td>
<td>(</td>
<td class="paramtype">size_t</td> <td class="paramname"><span class="paramname"><em>wsize</em></span></td><td>)</td>
<td></td>
</tr>
</table>
</div><div class="memdoc">
<p><b>v3</b>: Allocate a small object with its size expressed in machine words. </p>
<dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramname">wsize</td><td>The number of words, at most <a class="el" href="#ga070c011175b3a1de57a481966a57b8ba" title="Maximum number of machine words allowed for mi_wmalloc_small().">MI_SMALL_WSIZE_MAX</a>. Each word is <span class="tt">sizeof(size_t)</span> bytes, not necessarily the size of a pointer. </td></tr>
</table>
</dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>A pointer to newly allocated memory of at least <em class="arg">wsize</em> times <span class="tt">sizeof(size_t)</span> bytes, or <em class="arg">NULL</em> if out of memory. Like <a class="el" href="#ga7f050bc6b897da82692174f5fce59cde" title="Allocate a small object.">mi_malloc_small()</a>, this function is intended for runtime systems and does not check the size bound in release builds. The caller must ensure that <em class="arg">wsize</em> is small enough. Free the result with <a class="el" href="group__malloc.html#gaf2c7b89c327d1f60f59e68b9ea644d95" title="Free previously allocated memory.">mi_free()</a> or <a class="el" href="#ga2a8469764c38dcaf878f36e5f50e3610" title="v3: Can be used to free an object that was allocated with mi_malloc_small() or any allocation with a ...">mi_free_small()</a>. </dd></dl>
<dl class="section see"><dt>See also</dt><dd><a class="el" href="#ga7f050bc6b897da82692174f5fce59cde" title="Allocate a small object.">mi_malloc_small()</a>, <a class="el" href="group__constantsize.html#ga9cd44d925d34f7180922e12bbf594571" title="v3: Allocate a constant size object.">mi_malloc_csize()</a> </dd></dl>
</div>
</div>
<a id="ga4bed1e708005f676c2cc5f5627f3290a" name="ga4bed1e708005f676c2cc5f5627f3290a"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga4bed1e708005f676c2cc5f5627f3290a">◆ </a></span>mi_wsize_from_size()</h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">size_t mi_wsize_from_size </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><b>v3</b>: Convert a byte size to a number of <span class="tt">sizeof(size_t)</span> words, rounding up. </p>
<p><em class="arg">size</em> must not exceed <span class="tt">SIZE_MAX - (sizeof(size_t) - 1)</span> to avoid overflow. </p>
</div>
</div>
<a id="ga61113cc91b1d6de4ace7b693739b2352" name="ga61113cc91b1d6de4ace7b693739b2352"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga61113cc91b1d6de4ace7b693739b2352">◆ </a></span>mi_wzalloc_small()</h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void * mi_wzalloc_small </td>
<td>(</td>
<td class="paramtype">size_t</td> <td class="paramname"><span class="paramname"><em>wsize</em></span></td><td>)</td>
<td></td>
</tr>
</table>
</div><div class="memdoc">
<p><b>v3</b>: As <a class="el" href="#gaddce8f584e649a1b7ca48298dc52fe77" title="v3: Allocate a small object with its size expressed in machine words.">mi_wmalloc_small()</a>, but zero-initialize the allocation. </p>
<p><em class="arg">wsize</em> must not exceed <a class="el" href="#ga070c011175b3a1de57a481966a57b8ba" title="Maximum number of machine words allowed for mi_wmalloc_small().">MI_SMALL_WSIZE_MAX</a>. </p>
</div>
</div>
<a id="ga51c47637e81df0e2f13a2d7a2dec123e" name="ga51c47637e81df0e2f13a2d7a2dec123e"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga51c47637e81df0e2f13a2d7a2dec123e">◆ </a></span>mi_zalloc_small()</h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void * mi_zalloc_small </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 a zero initialized small object. </p>
<dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramname">size</td><td>The size in bytes, can be at most <a class="el" href="#ga1ea64283508718d9d645c38efc2f4305" title="Maximum size in bytes allowed for small allocations in mi_malloc_small, mi_zalloc_small,...">MI_SMALL_SIZE_MAX</a>. </td></tr>
</table>
</dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>a pointer to newly allocated zero-initialized memory of at least <em class="arg">size</em> bytes, or <em class="arg">NULL</em> if out of memory. This function is meant for use in run-time systems for best performance and does not check if <em class="arg">size</em> was indeed small – use with care! </dd></dl>
</div>
</div>
</div><!-- contents -->
</div><!-- doc-content -->
<div id="page-nav" class="page-nav-panel">
<div id="page-nav-resize-handle"></div>
<div id="page-nav-tree">
<div id="page-nav-contents">
</div><!-- page-nav-contents -->
</div><!-- page-nav-tree -->
</div><!-- page-nav -->
</div><!-- container -->
<!-- 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.18.0 </li>
</ul>
</div>
</body>
</html>