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/maps.c Source File</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>  </ul>
</div>
</div><!-- top -->
<div class="header">
  <div class="headertitle">
<div class="title">maps.c</div>  </div>
</div><!--header-->
<div class="contents">
<a href="maps_8c.html">Go to the documentation of this file.</a><div class="fragment"><div class="line"><a name="l00001"></a><span class="lineno">    1</span>&#160;<span class="comment">/*</span></div><div class="line"><a name="l00002"></a><span class="lineno">    2</span>&#160;<span class="comment"> * Copyright (c) 2014-2017 Pavel Kalvoda &lt;me@pavelkalvoda.com&gt;</span></div><div class="line"><a name="l00003"></a><span class="lineno">    3</span>&#160;<span class="comment"> *</span></div><div class="line"><a name="l00004"></a><span class="lineno">    4</span>&#160;<span class="comment"> * libcbor is free software; you can redistribute it and/or modify</span></div><div class="line"><a name="l00005"></a><span class="lineno">    5</span>&#160;<span class="comment"> * it under the terms of the MIT license. See LICENSE for details.</span></div><div class="line"><a name="l00006"></a><span class="lineno">    6</span>&#160;<span class="comment"> */</span></div><div class="line"><a name="l00007"></a><span class="lineno">    7</span>&#160;</div><div class="line"><a name="l00008"></a><span class="lineno">    8</span>&#160;<span class="preprocessor">#include &quot;<a class="code" href="maps_8h.html">maps.h</a>&quot;</span></div><div class="line"><a name="l00009"></a><span class="lineno">    9</span>&#160;<span class="preprocessor">#include &quot;<a class="code" href="memory__utils_8h.html">internal/memory_utils.h</a>&quot;</span></div><div class="line"><a name="l00010"></a><span class="lineno">   10</span>&#160;</div><div class="line"><a name="l00011"></a><span class="lineno"><a class="line" href="maps_8h.html#a1bbbee9c6f1eaa0ff4c19559fe109baf">   11</a></span>&#160;<span class="keywordtype">size_t</span> <a class="code" href="maps_8c.html#a1bbbee9c6f1eaa0ff4c19559fe109baf">cbor_map_size</a>(<span class="keyword">const</span> <a class="code" href="structcbor__item__t.html">cbor_item_t</a> *item)</div><div class="line"><a name="l00012"></a><span class="lineno">   12</span>&#160;{</div><div class="line"><a name="l00013"></a><span class="lineno">   13</span>&#160;    assert(<a class="code" href="common_8c.html#af0de041481b61922d0995b63f82d8ddd">cbor_isa_map</a>(item));</div><div class="line"><a name="l00014"></a><span class="lineno">   14</span>&#160;    <span class="keywordflow">return</span> item-&gt;<a class="code" href="structcbor__item__t.html#a7d97fa5cdf027ca0499c37ec19acf843">metadata</a>.<a class="code" href="unioncbor__item__metadata.html#ac497580bfcb0c0e47438a45407ac7b4e">map_metadata</a>.<a class="code" href="struct__cbor__map__metadata.html#a38136af91105ba320f1d95a4a4ceb4de">end_ptr</a>;</div><div class="line"><a name="l00015"></a><span class="lineno">   15</span>&#160;}</div><div class="line"><a name="l00016"></a><span class="lineno">   16</span>&#160;</div><div class="line"><a name="l00017"></a><span class="lineno"><a class="line" href="maps_8h.html#a3bf8e5779a3f1311b9b3f9e0a4e4f37e">   17</a></span>&#160;<span class="keywordtype">size_t</span> <a class="code" href="maps_8c.html#a3bf8e5779a3f1311b9b3f9e0a4e4f37e">cbor_map_allocated</a>(<span class="keyword">const</span> <a class="code" href="structcbor__item__t.html">cbor_item_t</a> *item)</div><div class="line"><a name="l00018"></a><span class="lineno">   18</span>&#160;{</div><div class="line"><a name="l00019"></a><span class="lineno">   19</span>&#160;    assert(<a class="code" href="common_8c.html#af0de041481b61922d0995b63f82d8ddd">cbor_isa_map</a>(item));</div><div class="line"><a name="l00020"></a><span class="lineno">   20</span>&#160;    <span class="keywordflow">return</span> item-&gt;<a class="code" href="structcbor__item__t.html#a7d97fa5cdf027ca0499c37ec19acf843">metadata</a>.<a class="code" href="unioncbor__item__metadata.html#ac497580bfcb0c0e47438a45407ac7b4e">map_metadata</a>.<a class="code" href="struct__cbor__map__metadata.html#a6eb16c3f11be5cecbbf8ab8bae689527">allocated</a>;</div><div class="line"><a name="l00021"></a><span class="lineno">   21</span>&#160;}</div><div class="line"><a name="l00022"></a><span class="lineno">   22</span>&#160;</div><div class="line"><a name="l00023"></a><span class="lineno"><a class="line" href="maps_8h.html#adab3c6ff2e51dcf2637567431cc6e76e">   23</a></span>&#160;<a class="code" href="structcbor__item__t.html">cbor_item_t</a> *<a class="code" href="maps_8c.html#adab3c6ff2e51dcf2637567431cc6e76e">cbor_new_definite_map</a>(<span class="keywordtype">size_t</span> size)</div><div class="line"><a name="l00024"></a><span class="lineno">   24</span>&#160;{</div><div class="line"><a name="l00025"></a><span class="lineno">   25</span>&#160;    <a class="code" href="structcbor__item__t.html">cbor_item_t</a> *item = <a class="code" href="common_8h.html#a07a781e9212fad361b0f59f7fc921057">_CBOR_MALLOC</a>(<span class="keyword">sizeof</span>(<a class="code" href="structcbor__item__t.html">cbor_item_t</a>));</div><div class="line"><a name="l00026"></a><span class="lineno">   26</span>&#160;    <span class="keywordflow">if</span> (item == NULL) {</div><div class="line"><a name="l00027"></a><span class="lineno">   27</span>&#160;        <span class="keywordflow">return</span> NULL;</div><div class="line"><a name="l00028"></a><span class="lineno">   28</span>&#160;    }</div><div class="line"><a name="l00029"></a><span class="lineno">   29</span>&#160;    *item = (<a class="code" href="data_8h.html#afdaa4bcbbdd295d719e39ce0b5519419">cbor_item_t</a>) {</div><div class="line"><a name="l00030"></a><span class="lineno">   30</span>&#160;        .<a class="code" href="structcbor__item__t.html#a6bb24fe655f086c6aa9a66d427e09cca">refcount</a> = 1,</div><div class="line"><a name="l00031"></a><span class="lineno">   31</span>&#160;        .type = <a class="code" href="data_8h.html#a3a931b40fc31b51cccfd1bc3dc5fc5d6a057fc3133cb4465f9eb734acfd195db2">CBOR_TYPE_MAP</a>,</div><div class="line"><a name="l00032"></a><span class="lineno">   32</span>&#160;        .metadata = {.map_metadata = {</div><div class="line"><a name="l00033"></a><span class="lineno">   33</span>&#160;            .allocated = size,</div><div class="line"><a name="l00034"></a><span class="lineno">   34</span>&#160;            .type = <a class="code" href="data_8h.html#a3cdab5e05cf46846e98b43cf77985589a051b0d1fe7ef7ccfc3824110b797429e">_CBOR_METADATA_DEFINITE</a>,</div><div class="line"><a name="l00035"></a><span class="lineno">   35</span>&#160;            .end_ptr = 0</div><div class="line"><a name="l00036"></a><span class="lineno">   36</span>&#160;        }},</div><div class="line"><a name="l00037"></a><span class="lineno">   37</span>&#160;        .data = <a class="code" href="memory__utils_8c.html#a7bfbe0ac179b30f38bfeb9fe432ad4ec">_cbor_alloc_multiple</a>(<span class="keyword">sizeof</span>(<span class="keyword">struct</span> <a class="code" href="structcbor__pair.html">cbor_pair</a>), size)</div><div class="line"><a name="l00038"></a><span class="lineno">   38</span>&#160;    };</div><div class="line"><a name="l00039"></a><span class="lineno">   39</span>&#160;    <span class="keywordflow">if</span> (item-&gt;<a class="code" href="structcbor__item__t.html#a5c6dde1dbef5aad748c49786352eef44">data</a> == NULL) {</div><div class="line"><a name="l00040"></a><span class="lineno">   40</span>&#160;        <a class="code" href="common_8h.html#a1300043d7db8adf6ab67f7b787f14635">_CBOR_FREE</a>(item);</div><div class="line"><a name="l00041"></a><span class="lineno">   41</span>&#160;        <span class="keywordflow">return</span> NULL;</div><div class="line"><a name="l00042"></a><span class="lineno">   42</span>&#160;    }</div><div class="line"><a name="l00043"></a><span class="lineno">   43</span>&#160;    <span class="keywordflow">return</span> item;</div><div class="line"><a name="l00044"></a><span class="lineno">   44</span>&#160;}</div><div class="line"><a name="l00045"></a><span class="lineno">   45</span>&#160;</div><div class="line"><a name="l00046"></a><span class="lineno"><a class="line" href="maps_8h.html#a58ac69227f48815754651e93d15a5051">   46</a></span>&#160;<a class="code" href="structcbor__item__t.html">cbor_item_t</a> *<a class="code" href="maps_8c.html#a58ac69227f48815754651e93d15a5051">cbor_new_indefinite_map</a>()</div><div class="line"><a name="l00047"></a><span class="lineno">   47</span>&#160;{</div><div class="line"><a name="l00048"></a><span class="lineno">   48</span>&#160;    <a class="code" href="structcbor__item__t.html">cbor_item_t</a> *item = <a class="code" href="common_8h.html#a07a781e9212fad361b0f59f7fc921057">_CBOR_MALLOC</a>(<span class="keyword">sizeof</span>(<a class="code" href="structcbor__item__t.html">cbor_item_t</a>));</div><div class="line"><a name="l00049"></a><span class="lineno">   49</span>&#160;    <span class="keywordflow">if</span> (item == NULL)</div><div class="line"><a name="l00050"></a><span class="lineno">   50</span>&#160;        <span class="keywordflow">return</span> NULL;</div><div class="line"><a name="l00051"></a><span class="lineno">   51</span>&#160;    *item = (<a class="code" href="data_8h.html#afdaa4bcbbdd295d719e39ce0b5519419">cbor_item_t</a>) {</div><div class="line"><a name="l00052"></a><span class="lineno">   52</span>&#160;        .<a class="code" href="structcbor__item__t.html#a6bb24fe655f086c6aa9a66d427e09cca">refcount</a> = 1,</div><div class="line"><a name="l00053"></a><span class="lineno">   53</span>&#160;        .type = <a class="code" href="data_8h.html#a3a931b40fc31b51cccfd1bc3dc5fc5d6a057fc3133cb4465f9eb734acfd195db2">CBOR_TYPE_MAP</a>,</div><div class="line"><a name="l00054"></a><span class="lineno">   54</span>&#160;        .metadata = {.map_metadata = {</div><div class="line"><a name="l00055"></a><span class="lineno">   55</span>&#160;            .allocated = 0,</div><div class="line"><a name="l00056"></a><span class="lineno">   56</span>&#160;            .type = <a class="code" href="data_8h.html#a3cdab5e05cf46846e98b43cf77985589ae598476995d503b404ccf78c21ab79ef">_CBOR_METADATA_INDEFINITE</a>,</div><div class="line"><a name="l00057"></a><span class="lineno">   57</span>&#160;            .end_ptr = 0</div><div class="line"><a name="l00058"></a><span class="lineno">   58</span>&#160;        }},</div><div class="line"><a name="l00059"></a><span class="lineno">   59</span>&#160;        .data = NULL</div><div class="line"><a name="l00060"></a><span class="lineno">   60</span>&#160;    };</div><div class="line"><a name="l00061"></a><span class="lineno">   61</span>&#160;</div><div class="line"><a name="l00062"></a><span class="lineno">   62</span>&#160;    <span class="keywordflow">return</span> item;</div><div class="line"><a name="l00063"></a><span class="lineno">   63</span>&#160;}</div><div class="line"><a name="l00064"></a><span class="lineno">   64</span>&#160;</div><div class="line"><a name="l00065"></a><span class="lineno">   65</span>&#160;</div><div class="line"><a name="l00066"></a><span class="lineno"><a class="line" href="maps_8h.html#a64c91e7ecba7cf7d0d4949153d681db8">   66</a></span>&#160;<span class="keywordtype">bool</span> <a class="code" href="maps_8c.html#a64c91e7ecba7cf7d0d4949153d681db8">_cbor_map_add_key</a>(<a class="code" href="structcbor__item__t.html">cbor_item_t</a> *item, <a class="code" href="structcbor__item__t.html">cbor_item_t</a> *key)</div><div class="line"><a name="l00067"></a><span class="lineno">   67</span>&#160;{</div><div class="line"><a name="l00068"></a><span class="lineno">   68</span>&#160;    assert(<a class="code" href="common_8c.html#af0de041481b61922d0995b63f82d8ddd">cbor_isa_map</a>(item));</div><div class="line"><a name="l00069"></a><span class="lineno">   69</span>&#160;    <span class="keyword">struct </span><a class="code" href="struct__cbor__map__metadata.html">_cbor_map_metadata</a> *metadata = (<span class="keyword">struct </span><a class="code" href="struct__cbor__map__metadata.html">_cbor_map_metadata</a> *) &amp;item-&gt;<a class="code" href="structcbor__item__t.html#a7d97fa5cdf027ca0499c37ec19acf843">metadata</a>;</div><div class="line"><a name="l00070"></a><span class="lineno">   70</span>&#160;    if (<a class="code" href="maps_8c.html#a0dccaa76ac293bb5a11dbca6d16f6253">cbor_map_is_definite</a>(item)) {</div><div class="line"><a name="l00071"></a><span class="lineno">   71</span>&#160;        <span class="keyword">struct </span><a class="code" href="structcbor__pair.html">cbor_pair</a> *data = <a class="code" href="maps_8c.html#a4cadc8eb7ae7ff8d3f73482fb24455c9">cbor_map_handle</a>(item);</div><div class="line"><a name="l00072"></a><span class="lineno">   72</span>&#160;        <span class="keywordflow">if</span> (metadata-&gt;<a class="code" href="struct__cbor__map__metadata.html#a38136af91105ba320f1d95a4a4ceb4de">end_ptr</a> &gt;= metadata-&gt;<a class="code" href="struct__cbor__map__metadata.html#a6eb16c3f11be5cecbbf8ab8bae689527">allocated</a>) {</div><div class="line"><a name="l00073"></a><span class="lineno">   73</span>&#160;            <span class="comment">/* Don&#39;t realloc definite preallocated map */</span></div><div class="line"><a name="l00074"></a><span class="lineno">   74</span>&#160;            <span class="keywordflow">return</span> <span class="keyword">false</span>;</div><div class="line"><a name="l00075"></a><span class="lineno">   75</span>&#160;        }</div><div class="line"><a name="l00076"></a><span class="lineno">   76</span>&#160;</div><div class="line"><a name="l00077"></a><span class="lineno">   77</span>&#160;        data[metadata-&gt;<a class="code" href="struct__cbor__map__metadata.html#a38136af91105ba320f1d95a4a4ceb4de">end_ptr</a>].<a class="code" href="structcbor__pair.html#a5122c22ad7ef32b2c6ae0a413caca7a1">key</a> = <a class="code" href="structcbor__pair.html#a5122c22ad7ef32b2c6ae0a413caca7a1">key</a>;</div><div class="line"><a name="l00078"></a><span class="lineno">   78</span>&#160;        data[metadata-&gt;<a class="code" href="struct__cbor__map__metadata.html#a38136af91105ba320f1d95a4a4ceb4de">end_ptr</a>++].<a class="code" href="structcbor__pair.html#a44bbea9cc120de72fc4871a05dc8ec85">value</a> = NULL;</div><div class="line"><a name="l00079"></a><span class="lineno">   79</span>&#160;    } <span class="keywordflow">else</span> {</div><div class="line"><a name="l00080"></a><span class="lineno">   80</span>&#160;        <span class="keywordflow">if</span> (metadata-&gt;<a class="code" href="struct__cbor__map__metadata.html#a38136af91105ba320f1d95a4a4ceb4de">end_ptr</a> &gt;= metadata-&gt;<a class="code" href="struct__cbor__map__metadata.html#a6eb16c3f11be5cecbbf8ab8bae689527">allocated</a>) {</div><div class="line"><a name="l00081"></a><span class="lineno">   81</span>&#160;            <span class="comment">/* Exponential realloc */</span></div><div class="line"><a name="l00082"></a><span class="lineno">   82</span>&#160;            <span class="comment">// Check for overflows first</span></div><div class="line"><a name="l00083"></a><span class="lineno">   83</span>&#160;            <span class="keywordflow">if</span> (!<a class="code" href="memory__utils_8c.html#abdee08be3f4cff35a94279fda66c4778">_cbor_safe_to_multiply</a>(CBOR_BUFFER_GROWTH, metadata-&gt;<a class="code" href="struct__cbor__map__metadata.html#a6eb16c3f11be5cecbbf8ab8bae689527">allocated</a>)) {</div><div class="line"><a name="l00084"></a><span class="lineno">   84</span>&#160;                <span class="keywordflow">return</span> <span class="keyword">false</span>;</div><div class="line"><a name="l00085"></a><span class="lineno">   85</span>&#160;            }</div><div class="line"><a name="l00086"></a><span class="lineno">   86</span>&#160;</div><div class="line"><a name="l00087"></a><span class="lineno">   87</span>&#160;            <span class="keywordtype">size_t</span> new_allocation = metadata-&gt;<a class="code" href="struct__cbor__map__metadata.html#a6eb16c3f11be5cecbbf8ab8bae689527">allocated</a> == 0 ? 1 : CBOR_BUFFER_GROWTH * metadata-&gt;<a class="code" href="struct__cbor__map__metadata.html#a6eb16c3f11be5cecbbf8ab8bae689527">allocated</a>;</div><div class="line"><a name="l00088"></a><span class="lineno">   88</span>&#160;</div><div class="line"><a name="l00089"></a><span class="lineno">   89</span>&#160;            <span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> * new_data = <a class="code" href="memory__utils_8c.html#afd7a22ccd3b44d6ff668e14c3a006e40">_cbor_realloc_multiple</a>(item-&gt;<a class="code" href="structcbor__item__t.html#a5c6dde1dbef5aad748c49786352eef44">data</a>, <span class="keyword">sizeof</span>(<span class="keyword">struct</span> <a class="code" href="structcbor__pair.html">cbor_pair</a>), new_allocation);</div><div class="line"><a name="l00090"></a><span class="lineno">   90</span>&#160;</div><div class="line"><a name="l00091"></a><span class="lineno">   91</span>&#160;            <span class="keywordflow">if</span> (new_data == NULL) {</div><div class="line"><a name="l00092"></a><span class="lineno">   92</span>&#160;                <span class="keywordflow">return</span> <span class="keyword">false</span>;</div><div class="line"><a name="l00093"></a><span class="lineno">   93</span>&#160;            }</div><div class="line"><a name="l00094"></a><span class="lineno">   94</span>&#160;</div><div class="line"><a name="l00095"></a><span class="lineno">   95</span>&#160;            item-&gt;<a class="code" href="structcbor__item__t.html#a5c6dde1dbef5aad748c49786352eef44">data</a> = new_data;</div><div class="line"><a name="l00096"></a><span class="lineno">   96</span>&#160;            metadata-&gt;<a class="code" href="struct__cbor__map__metadata.html#a6eb16c3f11be5cecbbf8ab8bae689527">allocated</a> = new_allocation;</div><div class="line"><a name="l00097"></a><span class="lineno">   97</span>&#160;        }</div><div class="line"><a name="l00098"></a><span class="lineno">   98</span>&#160;        <span class="keyword">struct </span><a class="code" href="structcbor__pair.html">cbor_pair</a> *data = <a class="code" href="maps_8c.html#a4cadc8eb7ae7ff8d3f73482fb24455c9">cbor_map_handle</a>(item);</div><div class="line"><a name="l00099"></a><span class="lineno">   99</span>&#160;        data[metadata-&gt;<a class="code" href="struct__cbor__map__metadata.html#a38136af91105ba320f1d95a4a4ceb4de">end_ptr</a>].<a class="code" href="structcbor__pair.html#a5122c22ad7ef32b2c6ae0a413caca7a1">key</a> = <a class="code" href="structcbor__pair.html#a5122c22ad7ef32b2c6ae0a413caca7a1">key</a>;</div><div class="line"><a name="l00100"></a><span class="lineno">  100</span>&#160;        data[metadata-&gt;<a class="code" href="struct__cbor__map__metadata.html#a38136af91105ba320f1d95a4a4ceb4de">end_ptr</a>++].<a class="code" href="structcbor__pair.html#a44bbea9cc120de72fc4871a05dc8ec85">value</a> = NULL;</div><div class="line"><a name="l00101"></a><span class="lineno">  101</span>&#160;    }</div><div class="line"><a name="l00102"></a><span class="lineno">  102</span>&#160;    <a class="code" href="common_8c.html#aa62e72f275c2f0fa604896bfed18e992">cbor_incref</a>(key);</div><div class="line"><a name="l00103"></a><span class="lineno">  103</span>&#160;    <span class="keywordflow">return</span> <span class="keyword">true</span>;</div><div class="line"><a name="l00104"></a><span class="lineno">  104</span>&#160;}</div><div class="line"><a name="l00105"></a><span class="lineno">  105</span>&#160;</div><div class="line"><a name="l00106"></a><span class="lineno"><a class="line" href="maps_8h.html#abb15486eebcd1c41c373613757505705">  106</a></span>&#160;<span class="keywordtype">bool</span> <a class="code" href="maps_8c.html#abb15486eebcd1c41c373613757505705">_cbor_map_add_value</a>(<a class="code" href="structcbor__item__t.html">cbor_item_t</a> *item, <a class="code" href="structcbor__item__t.html">cbor_item_t</a> *<a class="code" href="structcbor__pair.html#a44bbea9cc120de72fc4871a05dc8ec85">value</a>)</div><div class="line"><a name="l00107"></a><span class="lineno">  107</span>&#160;{</div><div class="line"><a name="l00108"></a><span class="lineno">  108</span>&#160;    assert(<a class="code" href="common_8c.html#af0de041481b61922d0995b63f82d8ddd">cbor_isa_map</a>(item));</div><div class="line"><a name="l00109"></a><span class="lineno">  109</span>&#160;    <a class="code" href="common_8c.html#aa62e72f275c2f0fa604896bfed18e992">cbor_incref</a>(value);</div><div class="line"><a name="l00110"></a><span class="lineno">  110</span>&#160;    <a class="code" href="maps_8c.html#a4cadc8eb7ae7ff8d3f73482fb24455c9">cbor_map_handle</a>(item)[</div><div class="line"><a name="l00111"></a><span class="lineno">  111</span>&#160;        <span class="comment">/* Move one back since we are assuming _add_key (which increased the ptr)</span></div><div class="line"><a name="l00112"></a><span class="lineno">  112</span>&#160;<span class="comment">         * was the previous operation on this object */</span></div><div class="line"><a name="l00113"></a><span class="lineno">  113</span>&#160;        item-&gt;<a class="code" href="structcbor__item__t.html#a7d97fa5cdf027ca0499c37ec19acf843">metadata</a>.<a class="code" href="unioncbor__item__metadata.html#ac497580bfcb0c0e47438a45407ac7b4e">map_metadata</a>.<a class="code" href="struct__cbor__map__metadata.html#a38136af91105ba320f1d95a4a4ceb4de">end_ptr</a> - 1</div><div class="line"><a name="l00114"></a><span class="lineno">  114</span>&#160;    ].<a class="code" href="structcbor__pair.html#a44bbea9cc120de72fc4871a05dc8ec85">value</a> = <a class="code" href="structcbor__pair.html#a44bbea9cc120de72fc4871a05dc8ec85">value</a>;</div><div class="line"><a name="l00115"></a><span class="lineno">  115</span>&#160;    <span class="keywordflow">return</span> <span class="keyword">true</span>;</div><div class="line"><a name="l00116"></a><span class="lineno">  116</span>&#160;}</div><div class="line"><a name="l00117"></a><span class="lineno">  117</span>&#160;</div><div class="line"><a name="l00118"></a><span class="lineno"><a class="line" href="maps_8h.html#af077a30d8258ab02307c24af28036fca">  118</a></span>&#160;<span class="keywordtype">bool</span> <a class="code" href="maps_8c.html#af077a30d8258ab02307c24af28036fca">cbor_map_add</a>(<a class="code" href="structcbor__item__t.html">cbor_item_t</a> *item, <span class="keyword">struct</span> <a class="code" href="structcbor__pair.html">cbor_pair</a> pair)</div><div class="line"><a name="l00119"></a><span class="lineno">  119</span>&#160;{</div><div class="line"><a name="l00120"></a><span class="lineno">  120</span>&#160;    assert(<a class="code" href="common_8c.html#af0de041481b61922d0995b63f82d8ddd">cbor_isa_map</a>(item));</div><div class="line"><a name="l00121"></a><span class="lineno">  121</span>&#160;    <span class="keywordflow">if</span> (!<a class="code" href="maps_8c.html#a64c91e7ecba7cf7d0d4949153d681db8">_cbor_map_add_key</a>(item, pair.<a class="code" href="structcbor__pair.html#a5122c22ad7ef32b2c6ae0a413caca7a1">key</a>))</div><div class="line"><a name="l00122"></a><span class="lineno">  122</span>&#160;        <span class="keywordflow">return</span> <span class="keyword">false</span>;</div><div class="line"><a name="l00123"></a><span class="lineno">  123</span>&#160;    <span class="keywordflow">return</span> <a class="code" href="maps_8c.html#abb15486eebcd1c41c373613757505705">_cbor_map_add_value</a>(item, pair.<a class="code" href="structcbor__pair.html#a44bbea9cc120de72fc4871a05dc8ec85">value</a>);</div><div class="line"><a name="l00124"></a><span class="lineno">  124</span>&#160;}</div><div class="line"><a name="l00125"></a><span class="lineno">  125</span>&#160;</div><div class="line"><a name="l00126"></a><span class="lineno"><a class="line" href="maps_8h.html#a0dccaa76ac293bb5a11dbca6d16f6253">  126</a></span>&#160;<span class="keywordtype">bool</span> <a class="code" href="maps_8c.html#a0dccaa76ac293bb5a11dbca6d16f6253">cbor_map_is_definite</a>(<span class="keyword">const</span> <a class="code" href="structcbor__item__t.html">cbor_item_t</a> *item)</div><div class="line"><a name="l00127"></a><span class="lineno">  127</span>&#160;{</div><div class="line"><a name="l00128"></a><span class="lineno">  128</span>&#160;    assert(<a class="code" href="common_8c.html#af0de041481b61922d0995b63f82d8ddd">cbor_isa_map</a>(item));</div><div class="line"><a name="l00129"></a><span class="lineno">  129</span>&#160;    <span class="keywordflow">return</span> item-&gt;<a class="code" href="structcbor__item__t.html#a7d97fa5cdf027ca0499c37ec19acf843">metadata</a>.<a class="code" href="unioncbor__item__metadata.html#ac497580bfcb0c0e47438a45407ac7b4e">map_metadata</a>.<a class="code" href="struct__cbor__map__metadata.html#aace4f7da19acf93e56eeb8ccf0fae7b5">type</a> == <a class="code" href="data_8h.html#a3cdab5e05cf46846e98b43cf77985589a051b0d1fe7ef7ccfc3824110b797429e">_CBOR_METADATA_DEFINITE</a>;</div><div class="line"><a name="l00130"></a><span class="lineno">  130</span>&#160;}</div><div class="line"><a name="l00131"></a><span class="lineno">  131</span>&#160;</div><div class="line"><a name="l00132"></a><span class="lineno"><a class="line" href="maps_8h.html#a941462383a3c8a6e3a60be9778cd1913">  132</a></span>&#160;<span class="keywordtype">bool</span> <a class="code" href="maps_8c.html#a941462383a3c8a6e3a60be9778cd1913">cbor_map_is_indefinite</a>(<span class="keyword">const</span> <a class="code" href="structcbor__item__t.html">cbor_item_t</a> *item)</div><div class="line"><a name="l00133"></a><span class="lineno">  133</span>&#160;{</div><div class="line"><a name="l00134"></a><span class="lineno">  134</span>&#160;    <span class="keywordflow">return</span> !<a class="code" href="maps_8c.html#a0dccaa76ac293bb5a11dbca6d16f6253">cbor_map_is_definite</a>(item);</div><div class="line"><a name="l00135"></a><span class="lineno">  135</span>&#160;}</div><div class="line"><a name="l00136"></a><span class="lineno">  136</span>&#160;</div><div class="line"><a name="l00137"></a><span class="lineno"><a class="line" href="maps_8h.html#a4cadc8eb7ae7ff8d3f73482fb24455c9">  137</a></span>&#160;<span class="keyword">struct </span><a class="code" href="structcbor__pair.html">cbor_pair</a> *<a class="code" href="maps_8c.html#a4cadc8eb7ae7ff8d3f73482fb24455c9">cbor_map_handle</a>(<span class="keyword">const</span> <a class="code" href="structcbor__item__t.html">cbor_item_t</a> *item)</div><div class="line"><a name="l00138"></a><span class="lineno">  138</span>&#160;{</div><div class="line"><a name="l00139"></a><span class="lineno">  139</span>&#160;    assert(<a class="code" href="common_8c.html#af0de041481b61922d0995b63f82d8ddd">cbor_isa_map</a>(item));</div><div class="line"><a name="l00140"></a><span class="lineno">  140</span>&#160;    <span class="keywordflow">return</span> (<span class="keyword">struct</span> <a class="code" href="structcbor__pair.html">cbor_pair</a> *) item-&gt;<a class="code" href="structcbor__item__t.html#a5c6dde1dbef5aad748c49786352eef44">data</a>;</div><div class="line"><a name="l00141"></a><span class="lineno">  141</span>&#160;}</div><div class="ttc" id="data_8h_html_afdaa4bcbbdd295d719e39ce0b5519419"><div class="ttname"><a href="data_8h.html#afdaa4bcbbdd295d719e39ce0b5519419">cbor_item_t</a></div><div class="ttdeci">struct cbor_item_t cbor_item_t</div><div class="ttdoc">The item handle. </div></div>
<div class="ttc" id="maps_8c_html_a3bf8e5779a3f1311b9b3f9e0a4e4f37e"><div class="ttname"><a href="maps_8c.html#a3bf8e5779a3f1311b9b3f9e0a4e4f37e">cbor_map_allocated</a></div><div class="ttdeci">size_t cbor_map_allocated(const cbor_item_t *item)</div><div class="ttdoc">Get the size of the allocated storage. </div><div class="ttdef"><b>Definition:</b> <a href="maps_8c_source.html#l00017">maps.c:17</a></div></div>
<div class="ttc" id="structcbor__item__t_html_a7d97fa5cdf027ca0499c37ec19acf843"><div class="ttname"><a href="structcbor__item__t.html#a7d97fa5cdf027ca0499c37ec19acf843">cbor_item_t::metadata</a></div><div class="ttdeci">union cbor_item_metadata metadata</div><div class="ttdoc">Discriminated by type. </div><div class="ttdef"><b>Definition:</b> <a href="data_8h_source.html#l00151">data.h:151</a></div></div>
<div class="ttc" id="unioncbor__item__metadata_html_ac497580bfcb0c0e47438a45407ac7b4e"><div class="ttname"><a href="unioncbor__item__metadata.html#ac497580bfcb0c0e47438a45407ac7b4e">cbor_item_metadata::map_metadata</a></div><div class="ttdeci">struct _cbor_map_metadata map_metadata</div><div class="ttdef"><b>Definition:</b> <a href="data_8h_source.html#l00143">data.h:143</a></div></div>
<div class="ttc" id="memory__utils_8c_html_afd7a22ccd3b44d6ff668e14c3a006e40"><div class="ttname"><a href="memory__utils_8c.html#afd7a22ccd3b44d6ff668e14c3a006e40">_cbor_realloc_multiple</a></div><div class="ttdeci">void * _cbor_realloc_multiple(void *pointer, size_t item_size, size_t item_count)</div><div class="ttdoc">Overflow-proof contiguous array reallocation. </div><div class="ttdef"><b>Definition:</b> <a href="memory__utils_8c_source.html#l00039">memory_utils.c:39</a></div></div>
<div class="ttc" id="structcbor__pair_html_a44bbea9cc120de72fc4871a05dc8ec85"><div class="ttname"><a href="structcbor__pair.html#a44bbea9cc120de72fc4871a05dc8ec85">cbor_pair::value</a></div><div class="ttdeci">cbor_item_t * value</div><div class="ttdef"><b>Definition:</b> <a href="data_8h_source.html#l00180">data.h:180</a></div></div>
<div class="ttc" id="maps_8h_html"><div class="ttname"><a href="maps_8h.html">maps.h</a></div></div>
<div class="ttc" id="maps_8c_html_a1bbbee9c6f1eaa0ff4c19559fe109baf"><div class="ttname"><a href="maps_8c.html#a1bbbee9c6f1eaa0ff4c19559fe109baf">cbor_map_size</a></div><div class="ttdeci">size_t cbor_map_size(const cbor_item_t *item)</div><div class="ttdoc">Get the number of pairs. </div><div class="ttdef"><b>Definition:</b> <a href="maps_8c_source.html#l00011">maps.c:11</a></div></div>
<div class="ttc" id="structcbor__pair_html_a5122c22ad7ef32b2c6ae0a413caca7a1"><div class="ttname"><a href="structcbor__pair.html#a5122c22ad7ef32b2c6ae0a413caca7a1">cbor_pair::key</a></div><div class="ttdeci">cbor_item_t * key</div><div class="ttdef"><b>Definition:</b> <a href="data_8h_source.html#l00180">data.h:180</a></div></div>
<div class="ttc" id="maps_8c_html_a64c91e7ecba7cf7d0d4949153d681db8"><div class="ttname"><a href="maps_8c.html#a64c91e7ecba7cf7d0d4949153d681db8">_cbor_map_add_key</a></div><div class="ttdeci">bool _cbor_map_add_key(cbor_item_t *item, cbor_item_t *key)</div><div class="ttdoc">Add a key to the map. </div><div class="ttdef"><b>Definition:</b> <a href="maps_8c_source.html#l00066">maps.c:66</a></div></div>
<div class="ttc" id="memory__utils_8c_html_a7bfbe0ac179b30f38bfeb9fe432ad4ec"><div class="ttname"><a href="memory__utils_8c.html#a7bfbe0ac179b30f38bfeb9fe432ad4ec">_cbor_alloc_multiple</a></div><div class="ttdeci">void * _cbor_alloc_multiple(size_t item_size, size_t item_count)</div><div class="ttdoc">Overflow-proof contiguous array allocation. </div><div class="ttdef"><b>Definition:</b> <a href="memory__utils_8c_source.html#l00030">memory_utils.c:30</a></div></div>
<div class="ttc" id="struct__cbor__map__metadata_html_a38136af91105ba320f1d95a4a4ceb4de"><div class="ttname"><a href="struct__cbor__map__metadata.html#a38136af91105ba320f1d95a4a4ceb4de">_cbor_map_metadata::end_ptr</a></div><div class="ttdeci">size_t end_ptr</div><div class="ttdef"><b>Definition:</b> <a href="data_8h_source.html#l00104">data.h:104</a></div></div>
<div class="ttc" id="common_8h_html_a1300043d7db8adf6ab67f7b787f14635"><div class="ttname"><a href="common_8h.html#a1300043d7db8adf6ab67f7b787f14635">_CBOR_FREE</a></div><div class="ttdeci">#define _CBOR_FREE</div><div class="ttdef"><b>Definition:</b> <a href="common_8h_source.html#l00086">common.h:86</a></div></div>
<div class="ttc" id="common_8h_html_a07a781e9212fad361b0f59f7fc921057"><div class="ttname"><a href="common_8h.html#a07a781e9212fad361b0f59f7fc921057">_CBOR_MALLOC</a></div><div class="ttdeci">#define _CBOR_MALLOC</div><div class="ttdef"><b>Definition:</b> <a href="common_8h_source.html#l00084">common.h:84</a></div></div>
<div class="ttc" id="maps_8c_html_a941462383a3c8a6e3a60be9778cd1913"><div class="ttname"><a href="maps_8c.html#a941462383a3c8a6e3a60be9778cd1913">cbor_map_is_indefinite</a></div><div class="ttdeci">bool cbor_map_is_indefinite(const cbor_item_t *item)</div><div class="ttdoc">Is this map indefinite? </div><div class="ttdef"><b>Definition:</b> <a href="maps_8c_source.html#l00132">maps.c:132</a></div></div>
<div class="ttc" id="structcbor__pair_html"><div class="ttname"><a href="structcbor__pair.html">cbor_pair</a></div><div class="ttdoc">Simple pair of items for use in maps. </div><div class="ttdef"><b>Definition:</b> <a href="data_8h_source.html#l00179">data.h:179</a></div></div>
<div class="ttc" id="data_8h_html_a3cdab5e05cf46846e98b43cf77985589ae598476995d503b404ccf78c21ab79ef"><div class="ttname"><a href="data_8h.html#a3cdab5e05cf46846e98b43cf77985589ae598476995d503b404ccf78c21ab79ef">_CBOR_METADATA_INDEFINITE</a></div><div class="ttdef"><b>Definition:</b> <a href="data_8h_source.html#l00064">data.h:64</a></div></div>
<div class="ttc" id="structcbor__item__t_html_a6bb24fe655f086c6aa9a66d427e09cca"><div class="ttname"><a href="structcbor__item__t.html#a6bb24fe655f086c6aa9a66d427e09cca">cbor_item_t::refcount</a></div><div class="ttdeci">size_t refcount</div><div class="ttdoc">Reference count - initialize to 0. </div><div class="ttdef"><b>Definition:</b> <a href="data_8h_source.html#l00153">data.h:153</a></div></div>
<div class="ttc" id="struct__cbor__map__metadata_html"><div class="ttname"><a href="struct__cbor__map__metadata.html">_cbor_map_metadata</a></div><div class="ttdoc">Maps specific metadata. </div><div class="ttdef"><b>Definition:</b> <a href="data_8h_source.html#l00102">data.h:102</a></div></div>
<div class="ttc" id="common_8c_html_aa62e72f275c2f0fa604896bfed18e992"><div class="ttname"><a href="common_8c.html#aa62e72f275c2f0fa604896bfed18e992">cbor_incref</a></div><div class="ttdeci">cbor_item_t * cbor_incref(cbor_item_t *item)</div><div class="ttdoc">Increases the reference count by one. </div><div class="ttdef"><b>Definition:</b> <a href="common_8c_source.html#l00093">common.c:93</a></div></div>
<div class="ttc" id="struct__cbor__map__metadata_html_aace4f7da19acf93e56eeb8ccf0fae7b5"><div class="ttname"><a href="struct__cbor__map__metadata.html#aace4f7da19acf93e56eeb8ccf0fae7b5">_cbor_map_metadata::type</a></div><div class="ttdeci">_cbor_dst_metadata type</div><div class="ttdef"><b>Definition:</b> <a href="data_8h_source.html#l00105">data.h:105</a></div></div>
<div class="ttc" id="common_8c_html_af0de041481b61922d0995b63f82d8ddd"><div class="ttname"><a href="common_8c.html#af0de041481b61922d0995b63f82d8ddd">cbor_isa_map</a></div><div class="ttdeci">bool cbor_isa_map(const cbor_item_t *item)</div><div class="ttdoc">Does the item have the appropriate major type? </div><div class="ttdef"><b>Definition:</b> <a href="common_8c_source.html#l00043">common.c:43</a></div></div>
<div class="ttc" id="maps_8c_html_a0dccaa76ac293bb5a11dbca6d16f6253"><div class="ttname"><a href="maps_8c.html#a0dccaa76ac293bb5a11dbca6d16f6253">cbor_map_is_definite</a></div><div class="ttdeci">bool cbor_map_is_definite(const cbor_item_t *item)</div><div class="ttdoc">Is this map definite? </div><div class="ttdef"><b>Definition:</b> <a href="maps_8c_source.html#l00126">maps.c:126</a></div></div>
<div class="ttc" id="data_8h_html_a3cdab5e05cf46846e98b43cf77985589a051b0d1fe7ef7ccfc3824110b797429e"><div class="ttname"><a href="data_8h.html#a3cdab5e05cf46846e98b43cf77985589a051b0d1fe7ef7ccfc3824110b797429e">_CBOR_METADATA_DEFINITE</a></div><div class="ttdef"><b>Definition:</b> <a href="data_8h_source.html#l00063">data.h:63</a></div></div>
<div class="ttc" id="maps_8c_html_abb15486eebcd1c41c373613757505705"><div class="ttname"><a href="maps_8c.html#abb15486eebcd1c41c373613757505705">_cbor_map_add_value</a></div><div class="ttdeci">bool _cbor_map_add_value(cbor_item_t *item, cbor_item_t *value)</div><div class="ttdoc">Add a value to the map. </div><div class="ttdef"><b>Definition:</b> <a href="maps_8c_source.html#l00106">maps.c:106</a></div></div>
<div class="ttc" id="memory__utils_8h_html"><div class="ttname"><a href="memory__utils_8h.html">memory_utils.h</a></div></div>
<div class="ttc" id="structcbor__item__t_html_a5c6dde1dbef5aad748c49786352eef44"><div class="ttname"><a href="structcbor__item__t.html#a5c6dde1dbef5aad748c49786352eef44">cbor_item_t::data</a></div><div class="ttdeci">unsigned char * data</div><div class="ttdoc">Raw data block - interpretation depends on metadata. </div><div class="ttdef"><b>Definition:</b> <a href="data_8h_source.html#l00157">data.h:157</a></div></div>
<div class="ttc" id="struct__cbor__map__metadata_html_a6eb16c3f11be5cecbbf8ab8bae689527"><div class="ttname"><a href="struct__cbor__map__metadata.html#a6eb16c3f11be5cecbbf8ab8bae689527">_cbor_map_metadata::allocated</a></div><div class="ttdeci">size_t allocated</div><div class="ttdef"><b>Definition:</b> <a href="data_8h_source.html#l00103">data.h:103</a></div></div>
<div class="ttc" id="maps_8c_html_a58ac69227f48815754651e93d15a5051"><div class="ttname"><a href="maps_8c.html#a58ac69227f48815754651e93d15a5051">cbor_new_indefinite_map</a></div><div class="ttdeci">cbor_item_t * cbor_new_indefinite_map()</div><div class="ttdoc">Create a new indefinite map. </div><div class="ttdef"><b>Definition:</b> <a href="maps_8c_source.html#l00046">maps.c:46</a></div></div>
<div class="ttc" id="maps_8c_html_af077a30d8258ab02307c24af28036fca"><div class="ttname"><a href="maps_8c.html#af077a30d8258ab02307c24af28036fca">cbor_map_add</a></div><div class="ttdeci">bool cbor_map_add(cbor_item_t *item, struct cbor_pair pair)</div><div class="ttdoc">Add a pair to the map. </div><div class="ttdef"><b>Definition:</b> <a href="maps_8c_source.html#l00118">maps.c:118</a></div></div>
<div class="ttc" id="memory__utils_8c_html_abdee08be3f4cff35a94279fda66c4778"><div class="ttname"><a href="memory__utils_8c.html#abdee08be3f4cff35a94279fda66c4778">_cbor_safe_to_multiply</a></div><div class="ttdeci">bool _cbor_safe_to_multiply(size_t a, size_t b)</div><div class="ttdoc">Can a and b be multiplied without overflowing size_t? </div><div class="ttdef"><b>Definition:</b> <a href="memory__utils_8c_source.html#l00025">memory_utils.c:25</a></div></div>
<div class="ttc" id="structcbor__item__t_html"><div class="ttname"><a href="structcbor__item__t.html">cbor_item_t</a></div><div class="ttdoc">The item handle. </div><div class="ttdef"><b>Definition:</b> <a href="data_8h_source.html#l00149">data.h:149</a></div></div>
<div class="ttc" id="maps_8c_html_a4cadc8eb7ae7ff8d3f73482fb24455c9"><div class="ttname"><a href="maps_8c.html#a4cadc8eb7ae7ff8d3f73482fb24455c9">cbor_map_handle</a></div><div class="ttdeci">struct cbor_pair * cbor_map_handle(const cbor_item_t *item)</div><div class="ttdoc">Get the pairs storage. </div><div class="ttdef"><b>Definition:</b> <a href="maps_8c_source.html#l00137">maps.c:137</a></div></div>
<div class="ttc" id="maps_8c_html_adab3c6ff2e51dcf2637567431cc6e76e"><div class="ttname"><a href="maps_8c.html#adab3c6ff2e51dcf2637567431cc6e76e">cbor_new_definite_map</a></div><div class="ttdeci">cbor_item_t * cbor_new_definite_map(size_t size)</div><div class="ttdoc">Create a new definite map. </div><div class="ttdef"><b>Definition:</b> <a href="maps_8c_source.html#l00023">maps.c:23</a></div></div>
<div class="ttc" id="data_8h_html_a3a931b40fc31b51cccfd1bc3dc5fc5d6a057fc3133cb4465f9eb734acfd195db2"><div class="ttname"><a href="data_8h.html#a3a931b40fc31b51cccfd1bc3dc5fc5d6a057fc3133cb4465f9eb734acfd195db2">CBOR_TYPE_MAP</a></div><div class="ttdoc">5 - maps </div><div class="ttdef"><b>Definition:</b> <a href="data_8h_source.html#l00030">data.h:30</a></div></div>
</div><!-- fragment --></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>