Training courses

Kernel and Embedded Linux

Bootlin training courses

Embedded Linux, kernel,
Yocto Project, Buildroot, real-time,
graphics, boot time, debugging...

Bootlin logo

Elixir Cross Referencer

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://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.8.12"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>libcbor: src/cbor/internal/memory_utils.c 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" />
<link href="customdoxygen.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="projectalign" style="padding-left: 0.5em;">
   <div id="projectname">libcbor
   &#160;<span id="projectnumber">0.5.0</span>
   </div>
   <div id="projectbrief">libcbor is a C library for parsing and generating CBOR, the general-purpose schema-less binary data format.</div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.12 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search",false,'Search');
</script>
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
$(function() {
  initMenu('',true,false,'search.php','Search');
  $(document).ready(function() { init_search(); });
});
</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_68267d1309a1af8e8297ef4c3efbcdba.html">src</a></li><li class="navelem"><a class="el" href="dir_cb565ba51d82ea933604984cbab6233d.html">cbor</a></li><li class="navelem"><a class="el" href="dir_3ebe94c85f6786bf802771098c1d09bb.html">internal</a></li>  </ul>
</div>
</div><!-- top -->
<div class="header">
  <div class="summary">
<a href="#func-members">Functions</a>  </div>
  <div class="headertitle">
<div class="title">memory_utils.c File Reference</div>  </div>
</div><!--header-->
<div class="contents">
<div class="textblock"><code>#include &quot;<a class="el" href="memory__utils_8h_source.html">memory_utils.h</a>&quot;</code><br />
<code>#include &quot;<a class="el" href="common_8h_source.html">cbor/common.h</a>&quot;</code><br />
</div>
<p><a href="memory__utils_8c_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="func-members"></a>
Functions</h2></td></tr>
<tr class="memitem:ab45e9067ef782bb27cf846dc94eb4669"><td class="memItemLeft" align="right" valign="top">size_t&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="memory__utils_8c.html#ab45e9067ef782bb27cf846dc94eb4669">_cbor_highest_bit</a> (size_t number)</td></tr>
<tr class="memdesc:ab45e9067ef782bb27cf846dc94eb4669"><td class="mdescLeft">&#160;</td><td class="mdescRight">Highest on bit position.  <a href="#ab45e9067ef782bb27cf846dc94eb4669">More...</a><br /></td></tr>
<tr class="separator:ab45e9067ef782bb27cf846dc94eb4669"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:abdee08be3f4cff35a94279fda66c4778"><td class="memItemLeft" align="right" valign="top">bool&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="memory__utils_8c.html#abdee08be3f4cff35a94279fda66c4778">_cbor_safe_to_multiply</a> (size_t a, size_t b)</td></tr>
<tr class="memdesc:abdee08be3f4cff35a94279fda66c4778"><td class="mdescLeft">&#160;</td><td class="mdescRight">Can a and b be multiplied without overflowing size_t?  <a href="#abdee08be3f4cff35a94279fda66c4778">More...</a><br /></td></tr>
<tr class="separator:abdee08be3f4cff35a94279fda66c4778"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a7bfbe0ac179b30f38bfeb9fe432ad4ec"><td class="memItemLeft" align="right" valign="top">void *&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="memory__utils_8c.html#a7bfbe0ac179b30f38bfeb9fe432ad4ec">_cbor_alloc_multiple</a> (size_t item_size, size_t item_count)</td></tr>
<tr class="memdesc:a7bfbe0ac179b30f38bfeb9fe432ad4ec"><td class="mdescLeft">&#160;</td><td class="mdescRight">Overflow-proof contiguous array allocation.  <a href="#a7bfbe0ac179b30f38bfeb9fe432ad4ec">More...</a><br /></td></tr>
<tr class="separator:a7bfbe0ac179b30f38bfeb9fe432ad4ec"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:afd7a22ccd3b44d6ff668e14c3a006e40"><td class="memItemLeft" align="right" valign="top">void *&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="memory__utils_8c.html#afd7a22ccd3b44d6ff668e14c3a006e40">_cbor_realloc_multiple</a> (void *pointer, size_t item_size, size_t item_count)</td></tr>
<tr class="memdesc:afd7a22ccd3b44d6ff668e14c3a006e40"><td class="mdescLeft">&#160;</td><td class="mdescRight">Overflow-proof contiguous array reallocation.  <a href="#afd7a22ccd3b44d6ff668e14c3a006e40">More...</a><br /></td></tr>
<tr class="separator:afd7a22ccd3b44d6ff668e14c3a006e40"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table>
<h2 class="groupheader">Function Documentation</h2>
<a id="a7bfbe0ac179b30f38bfeb9fe432ad4ec"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a7bfbe0ac179b30f38bfeb9fe432ad4ec">&sect;&nbsp;</a></span>_cbor_alloc_multiple()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void* _cbor_alloc_multiple </td>
          <td>(</td>
          <td class="paramtype">size_t&#160;</td>
          <td class="paramname"><em>item_size</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">size_t&#160;</td>
          <td class="paramname"><em>item_count</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Overflow-proof contiguous array allocation. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">item_size</td><td></td></tr>
    <tr><td class="paramname">item_count</td><td></td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>Region of item_size * item_count bytes, or NULL if the total size overflows size_t or the underlying allocator failed </dd></dl>

<p>Definition at line <a class="el" href="memory__utils_8c_source.html#l00030">30</a> of file <a class="el" href="memory__utils_8c_source.html">memory_utils.c</a>.</p>

</div>
</div>
<a id="ab45e9067ef782bb27cf846dc94eb4669"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ab45e9067ef782bb27cf846dc94eb4669">&sect;&nbsp;</a></span>_cbor_highest_bit()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">size_t _cbor_highest_bit </td>
          <td>(</td>
          <td class="paramtype">size_t&#160;</td>
          <td class="paramname"><em>number</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Highest on bit position. </p>

<p>Definition at line <a class="el" href="memory__utils_8c_source.html#l00014">14</a> of file <a class="el" href="memory__utils_8c_source.html">memory_utils.c</a>.</p>

</div>
</div>
<a id="afd7a22ccd3b44d6ff668e14c3a006e40"></a>
<h2 class="memtitle"><span class="permalink"><a href="#afd7a22ccd3b44d6ff668e14c3a006e40">&sect;&nbsp;</a></span>_cbor_realloc_multiple()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void* _cbor_realloc_multiple </td>
          <td>(</td>
          <td class="paramtype">void *&#160;</td>
          <td class="paramname"><em>pointer</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">size_t&#160;</td>
          <td class="paramname"><em>item_size</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">size_t&#160;</td>
          <td class="paramname"><em>item_count</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Overflow-proof contiguous array reallocation. </p>
<p>This implements the OpenBSD <code>reallocarray</code> functionality.</p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">pointer</td><td></td></tr>
    <tr><td class="paramname">item_size</td><td></td></tr>
    <tr><td class="paramname">item_count</td><td></td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>Realloc'd of item_size * item_count bytes, or NULL if the total size overflows size_t or the underlying allocator failed </dd></dl>

<p>Definition at line <a class="el" href="memory__utils_8c_source.html#l00039">39</a> of file <a class="el" href="memory__utils_8c_source.html">memory_utils.c</a>.</p>

</div>
</div>
<a id="abdee08be3f4cff35a94279fda66c4778"></a>
<h2 class="memtitle"><span class="permalink"><a href="#abdee08be3f4cff35a94279fda66c4778">&sect;&nbsp;</a></span>_cbor_safe_to_multiply()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">bool _cbor_safe_to_multiply </td>
          <td>(</td>
          <td class="paramtype">size_t&#160;</td>
          <td class="paramname"><em>a</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">size_t&#160;</td>
          <td class="paramname"><em>b</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Can a and b be multiplied without overflowing size_t? </p>

<p>Definition at line <a class="el" href="memory__utils_8c_source.html#l00025">25</a> of file <a class="el" href="memory__utils_8c_source.html">memory_utils.c</a>.</p>

</div>
</div>
</div><!-- contents -->
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
Generated on Mon Feb 6 2017 00:26:19 for libcbor by &#160;<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/>
</a> 1.8.12
</small></address>
</body>
</html>