Files
TweinStein/Documentation/html/heap_8h.html

307 lines
16 KiB
HTML
Raw Normal View History

2026-06-12 02:55:04 -07:00
<!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">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.9.1"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>RTOS_MSPM0: RTOS_Labs_common/heap.h File Reference</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>
<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" />
</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 style="height: 56px;">
<td id="projectlogo"><img alt="Logo" src="RobotSensors.png"/></td>
<td id="projectalign" style="padding-left: 0.5em;">
<div id="projectname">RTOS_MSPM0
&#160;<span id="projectnumber">1.1</span>
</div>
<div id="projectbrief">ECE445M starter code</div>
</td>
</tr>
</tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.9.1 -->
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
var searchBox = new SearchBox("searchBox", "search",false,'Search','.html');
/* @license-end */
</script>
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
$(function() {
initMenu('',true,false,'search.php','Search');
$(document).ready(function() { init_search(); });
});
/* @license-end */</script>
<div id="main-nav"></div>
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
onmouseover="return searchBox.OnSearchSelectShow()"
onmouseout="return searchBox.OnSearchSelectHide()"
onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>
<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0"
name="MSearchResults" id="MSearchResults">
</iframe>
</div>
<div id="nav-path" class="navpath">
<ul>
<li class="navelem"><a class="el" href="dir_d9737668015ddda3d9b152d7c8d1103c.html">RTOS_Labs_common</a></li> </ul>
</div>
</div><!-- top -->
<div class="header">
<div class="summary">
<a href="#nested-classes">Data Structures</a> &#124;
<a href="#typedef-members">Typedefs</a> &#124;
<a href="#func-members">Functions</a> </div>
<div class="headertitle">
<div class="title">heap.h File Reference</div> </div>
</div><!--header-->
<div class="contents">
<p>heap memory manager
<a href="#details">More...</a></p>
<div class="textblock"><code>#include &lt;stdint.h&gt;</code><br />
</div>
<p><a href="heap_8h_source.html">Go to the source code of this file.</a></p>
<table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="nested-classes"></a>
Data Structures</h2></td></tr>
<tr class="memitem:"><td class="memItemLeft" align="right" valign="top">struct &#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="structheap__stats.html">heap_stats</a></td></tr>
<tr class="separator:"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="typedef-members"></a>
Typedefs</h2></td></tr>
<tr class="memitem:a2f6bb27b3472e49457d66684f5c0d2c9"><td class="memItemLeft" align="right" valign="top"><a id="a2f6bb27b3472e49457d66684f5c0d2c9"></a>
typedef struct <a class="el" href="structheap__stats.html">heap_stats</a>&#160;</td><td class="memItemRight" valign="bottom"><b>heap_stats_t</b></td></tr>
<tr class="separator:a2f6bb27b3472e49457d66684f5c0d2c9"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="func-members"></a>
Functions</h2></td></tr>
<tr class="memitem:a927f9f9522b87a3ccaee6c68efbf2081"><td class="memItemLeft" align="right" valign="top">int32_t&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="heap_8h.html#a927f9f9522b87a3ccaee6c68efbf2081">Heap_Init</a> (void)</td></tr>
<tr class="memdesc:a927f9f9522b87a3ccaee6c68efbf2081"><td class="mdescLeft">&#160;</td><td class="mdescRight">Initializes/resets the heap to a clean state where no memory is allocated. <a href="heap_8h.html#a927f9f9522b87a3ccaee6c68efbf2081">More...</a><br /></td></tr>
<tr class="separator:a927f9f9522b87a3ccaee6c68efbf2081"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a178556e87b1f3e4c72b419d2c02cd1d4"><td class="memItemLeft" align="right" valign="top">void *&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="heap_8h.html#a178556e87b1f3e4c72b419d2c02cd1d4">Heap_Malloc</a> (int32_t desiredBytes)</td></tr>
<tr class="memdesc:a178556e87b1f3e4c72b419d2c02cd1d4"><td class="mdescLeft">&#160;</td><td class="mdescRight">Allocate memory. <a href="heap_8h.html#a178556e87b1f3e4c72b419d2c02cd1d4">More...</a><br /></td></tr>
<tr class="separator:a178556e87b1f3e4c72b419d2c02cd1d4"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a2844e924abca6846ed9407e57ed828ab"><td class="memItemLeft" align="right" valign="top">void *&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="heap_8h.html#a2844e924abca6846ed9407e57ed828ab">Heap_Calloc</a> (int32_t desiredBytes)</td></tr>
<tr class="memdesc:a2844e924abca6846ed9407e57ed828ab"><td class="mdescLeft">&#160;</td><td class="mdescRight">Zero-allocate memory. <a href="heap_8h.html#a2844e924abca6846ed9407e57ed828ab">More...</a><br /></td></tr>
<tr class="separator:a2844e924abca6846ed9407e57ed828ab"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:af02282279b1745e0e1485c5bc7d19098"><td class="memItemLeft" align="right" valign="top">void *&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="heap_8h.html#af02282279b1745e0e1485c5bc7d19098">Heap_Realloc</a> (void *oldBlock, int32_t desiredBytes)</td></tr>
<tr class="memdesc:af02282279b1745e0e1485c5bc7d19098"><td class="mdescLeft">&#160;</td><td class="mdescRight">Grow/shrink memory. <a href="heap_8h.html#af02282279b1745e0e1485c5bc7d19098">More...</a><br /></td></tr>
<tr class="separator:af02282279b1745e0e1485c5bc7d19098"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a0c2946e20398909f89ebf1bc344b9f60"><td class="memItemLeft" align="right" valign="top">int32_t&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="heap_8h.html#a0c2946e20398909f89ebf1bc344b9f60">Heap_Free</a> (void *pointer)</td></tr>
<tr class="memdesc:a0c2946e20398909f89ebf1bc344b9f60"><td class="mdescLeft">&#160;</td><td class="mdescRight">Free memory. <a href="heap_8h.html#a0c2946e20398909f89ebf1bc344b9f60">More...</a><br /></td></tr>
<tr class="separator:a0c2946e20398909f89ebf1bc344b9f60"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a9c528dbd61f8df446f759961e3c09396"><td class="memItemLeft" align="right" valign="top">int32_t&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="heap_8h.html#a9c528dbd61f8df446f759961e3c09396">Heap_Stats</a> (<a class="el" href="structheap__stats.html">heap_stats_t</a> *stats)</td></tr>
<tr class="memdesc:a9c528dbd61f8df446f759961e3c09396"><td class="mdescLeft">&#160;</td><td class="mdescRight">Get heap usage. <a href="heap_8h.html#a9c528dbd61f8df446f759961e3c09396">More...</a><br /></td></tr>
<tr class="separator:a9c528dbd61f8df446f759961e3c09396"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table>
<a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2>
<div class="textblock"><p>heap memory manager </p>
<p>Dynamic memory management on a heap </p><dl class="section version"><dt>Version</dt><dd>V1.0 </dd></dl>
<dl class="section author"><dt>Author</dt><dd>Valvano (originally by Jacob Egner) </dd></dl>
<dl class="section copyright"><dt>Copyright</dt><dd>Copyright 2026 by Jonathan W. Valvano, <a href="#" onclick="location.href='mai'+'lto:'+'val'+'va'+'no@'+'ma'+'il.'+'ut'+'exa'+'s.'+'edu'; return false;">valva<span style="display: none;">.nosp@m.</span>no@m<span style="display: none;">.nosp@m.</span>ail.u<span style="display: none;">.nosp@m.</span>texa<span style="display: none;">.nosp@m.</span>s.edu</a>, </dd></dl>
<dl class="section warning"><dt>Warning</dt><dd>AS-IS </dd></dl>
<dl class="section note"><dt>Note</dt><dd>For more information see <a href="http://users.ece.utexas.edu/~valvano/">http://users.ece.utexas.edu/~valvano/</a> </dd></dl>
<dl class="section date"><dt>Date</dt><dd>Jan 10, 2026 </dd></dl>
</div><h2 class="groupheader">Function Documentation</h2>
<a id="a2844e924abca6846ed9407e57ed828ab"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a2844e924abca6846ed9407e57ed828ab">&#9670;&nbsp;</a></span>Heap_Calloc()</h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void* Heap_Calloc </td>
<td>(</td>
<td class="paramtype">int32_t&#160;</td>
<td class="paramname"><em>desiredBytes</em></td><td>)</td>
<td></td>
</tr>
</table>
</div><div class="memdoc">
<p>Zero-allocate memory. </p>
<p>Allocate memory, allocated memory is initialized to 0 (zeroed out) </p><dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramname">desiredBytes</td><td>desired number of bytes to allocate </td></tr>
</table>
</dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>void* pointing to the allocated memory block or will return NULL if there isn't sufficient space to satisfy allocation request </dd></dl>
</div>
</div>
<a id="a0c2946e20398909f89ebf1bc344b9f60"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a0c2946e20398909f89ebf1bc344b9f60">&#9670;&nbsp;</a></span>Heap_Free()</h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">int32_t Heap_Free </td>
<td>(</td>
<td class="paramtype">void *&#160;</td>
<td class="paramname"><em>pointer</em></td><td>)</td>
<td></td>
</tr>
</table>
</div><div class="memdoc">
<p>Free memory. </p>
<p>Return a block to the heap </p><dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramname">pointer</td><td>to memory to unallocate </td></tr>
</table>
</dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>0 if everything is ok, non-zero in case of error (e.g. invalid pointer or trying to unallocate memory that has already been unallocated) </dd></dl>
</div>
</div>
<a id="a927f9f9522b87a3ccaee6c68efbf2081"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a927f9f9522b87a3ccaee6c68efbf2081">&#9670;&nbsp;</a></span>Heap_Init()</h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">int32_t Heap_Init </td>
<td>(</td>
<td class="paramtype">void&#160;</td>
<td class="paramname"></td><td>)</td>
<td></td>
</tr>
</table>
</div><div class="memdoc">
<p>Initializes/resets the heap to a clean state where no memory is allocated. </p>
<p>Initialize the Heap </p><dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramname">none</td><td></td></tr>
</table>
</dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>always 0 (success) </dd></dl>
</div>
</div>
<a id="a178556e87b1f3e4c72b419d2c02cd1d4"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a178556e87b1f3e4c72b419d2c02cd1d4">&#9670;&nbsp;</a></span>Heap_Malloc()</h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void* Heap_Malloc </td>
<td>(</td>
<td class="paramtype">int32_t&#160;</td>
<td class="paramname"><em>desiredBytes</em></td><td>)</td>
<td></td>
</tr>
</table>
</div><div class="memdoc">
<p>Allocate memory. </p>
<p>Allocate memory, data not initialized </p><dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramname">desiredBytes</td><td>desired number of bytes to allocate </td></tr>
</table>
</dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>void* pointing to the allocated memory or will return NULL if there isn't sufficient space to satisfy allocation request </dd></dl>
</div>
</div>
<a id="af02282279b1745e0e1485c5bc7d19098"></a>
<h2 class="memtitle"><span class="permalink"><a href="#af02282279b1745e0e1485c5bc7d19098">&#9670;&nbsp;</a></span>Heap_Realloc()</h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void* Heap_Realloc </td>
<td>(</td>
<td class="paramtype">void *&#160;</td>
<td class="paramname"><em>oldBlock</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">int32_t&#160;</td>
<td class="paramname"><em>desiredBytes</em>&#160;</td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td>
</tr>
</table>
</div><div class="memdoc">
<p>Grow/shrink memory. </p>
<p>Reallocate buffer to a new size. The given block may be unallocated and its contents copied to a new block </p><dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramname">oldBlock</td><td>pointer to a block </td></tr>
<tr><td class="paramname">desiredBytes</td><td>a desired number of bytes for a new block </td></tr>
</table>
</dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>void* pointing to the new block or will return NULL if there is any reason the reallocation can't be completed </dd></dl>
</div>
</div>
<a id="a9c528dbd61f8df446f759961e3c09396"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a9c528dbd61f8df446f759961e3c09396">&#9670;&nbsp;</a></span>Heap_Stats()</h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">int32_t Heap_Stats </td>
<td>(</td>
<td class="paramtype"><a class="el" href="structheap__stats.html">heap_stats_t</a> *&#160;</td>
<td class="paramname"><em>stats</em></td><td>)</td>
<td></td>
</tr>
</table>
</div><div class="memdoc">
<p>Get heap usage. </p>
<p>Return the current usage status of the heap </p><dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramname">reference</td><td>to a heap_stats_t that returns the current usage of the heap </td></tr>
</table>
</dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>0 in case of success, non-zeror in case of error (e.g. corrupted heap) </dd></dl>
</div>
</div>
</div><!-- contents -->
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
Generated by&#160;<a href="https://www.doxygen.org/index.html"><img class="footer" src="doxygen.svg" width="104" height="31" alt="doxygen"/></a> 1.9.1
</small></address>
</body>
</html>