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/bytestrings.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">bytestrings.c</div>  </div>
</div><!--header-->
<div class="contents">
<a href="bytestrings_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 &lt;string.h&gt;</span></div><div class="line"><a name="l00009"></a><span class="lineno">    9</span>&#160;<span class="preprocessor">#include &quot;<a class="code" href="bytestrings_8h.html">bytestrings.h</a>&quot;</span></div><div class="line"><a name="l00010"></a><span class="lineno">   10</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="l00011"></a><span class="lineno">   11</span>&#160;</div><div class="line"><a name="l00012"></a><span class="lineno"><a class="line" href="bytestrings_8h.html#a7c15a63fdc3830707eac0877a261f1cd">   12</a></span>&#160;<span class="keywordtype">size_t</span> <a class="code" href="bytestrings_8c.html#a7c15a63fdc3830707eac0877a261f1cd">cbor_bytestring_length</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="l00013"></a><span class="lineno">   13</span>&#160;{</div><div class="line"><a name="l00014"></a><span class="lineno">   14</span>&#160;    assert(<a class="code" href="common_8c.html#adedaf37527b8d8261e287a0001e5a190">cbor_isa_bytestring</a>(item));</div><div class="line"><a name="l00015"></a><span class="lineno">   15</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#a90851d347147760c9cef8d7af485d006">bytestring_metadata</a>.<a class="code" href="struct__cbor__bytestring__metadata.html#ad20fa7f7cec11db8076419169347ff75">length</a>;</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">   17</span>&#160;</div><div class="line"><a name="l00018"></a><span class="lineno"><a class="line" href="bytestrings_8h.html#a05c09e147b0a244abc481b0b078ebcb9">   18</a></span>&#160;<span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> *<a class="code" href="bytestrings_8c.html#a2c9d6feda3d0f87782168fa817f83be6">cbor_bytestring_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="l00019"></a><span class="lineno">   19</span>&#160;{</div><div class="line"><a name="l00020"></a><span class="lineno">   20</span>&#160;    assert(<a class="code" href="common_8c.html#adedaf37527b8d8261e287a0001e5a190">cbor_isa_bytestring</a>(item));</div><div class="line"><a name="l00021"></a><span class="lineno">   21</span>&#160;    <span class="keywordflow">return</span> item-&gt;<a class="code" href="structcbor__item__t.html#a5c6dde1dbef5aad748c49786352eef44">data</a>;</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">   23</span>&#160;</div><div class="line"><a name="l00024"></a><span class="lineno"><a class="line" href="bytestrings_8h.html#a368222dbbcea25e06469524e26587e2a">   24</a></span>&#160;<span class="keywordtype">bool</span> <a class="code" href="bytestrings_8c.html#a368222dbbcea25e06469524e26587e2a">cbor_bytestring_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="l00025"></a><span class="lineno">   25</span>&#160;{</div><div class="line"><a name="l00026"></a><span class="lineno">   26</span>&#160;    assert(<a class="code" href="common_8c.html#adedaf37527b8d8261e287a0001e5a190">cbor_isa_bytestring</a>(item));</div><div class="line"><a name="l00027"></a><span class="lineno">   27</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#a90851d347147760c9cef8d7af485d006">bytestring_metadata</a>.<a class="code" href="struct__cbor__bytestring__metadata.html#ab43be7eca10ef7f0501d9f87482e27c3">type</a> == <a class="code" href="data_8h.html#a3cdab5e05cf46846e98b43cf77985589a051b0d1fe7ef7ccfc3824110b797429e">_CBOR_METADATA_DEFINITE</a>;</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;</div><div class="line"><a name="l00030"></a><span class="lineno"><a class="line" href="bytestrings_8h.html#a3a6c450f105bb18b6b56d20f0de4786a">   30</a></span>&#160;<span class="keywordtype">bool</span> <a class="code" href="bytestrings_8c.html#a3a6c450f105bb18b6b56d20f0de4786a">cbor_bytestring_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="l00031"></a><span class="lineno">   31</span>&#160;{</div><div class="line"><a name="l00032"></a><span class="lineno">   32</span>&#160;    <span class="keywordflow">return</span> !<a class="code" href="bytestrings_8c.html#a368222dbbcea25e06469524e26587e2a">cbor_bytestring_is_definite</a>(item);</div><div class="line"><a name="l00033"></a><span class="lineno">   33</span>&#160;}</div><div class="line"><a name="l00034"></a><span class="lineno">   34</span>&#160;</div><div class="line"><a name="l00035"></a><span class="lineno"><a class="line" href="bytestrings_8h.html#a86fc646f4520b90c85a704d27b46e69e">   35</a></span>&#160;<a class="code" href="structcbor__item__t.html">cbor_item_t</a> *<a class="code" href="bytestrings_8c.html#a86fc646f4520b90c85a704d27b46e69e">cbor_new_definite_bytestring</a>()</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;    <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="l00038"></a><span class="lineno">   38</span>&#160;    *item = (<a class="code" href="data_8h.html#afdaa4bcbbdd295d719e39ce0b5519419">cbor_item_t</a>) {</div><div class="line"><a name="l00039"></a><span class="lineno">   39</span>&#160;        .<a class="code" href="structcbor__item__t.html#a6bb24fe655f086c6aa9a66d427e09cca">refcount</a> = 1,</div><div class="line"><a name="l00040"></a><span class="lineno">   40</span>&#160;        .type = <a class="code" href="data_8h.html#a3a931b40fc31b51cccfd1bc3dc5fc5d6a70b9f0b5958c8d51f15ad7bb7c4af01d">CBOR_TYPE_BYTESTRING</a>,</div><div class="line"><a name="l00041"></a><span class="lineno">   41</span>&#160;        .metadata = {.bytestring_metadata = {<a class="code" href="data_8h.html#a3cdab5e05cf46846e98b43cf77985589a051b0d1fe7ef7ccfc3824110b797429e">_CBOR_METADATA_DEFINITE</a>, 0}}</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="bytestrings_8h.html#a6de9d6387e856c33d2ef8e8e9fdac0ac">   46</a></span>&#160;<a class="code" href="structcbor__item__t.html">cbor_item_t</a> *<a class="code" href="bytestrings_8c.html#a6de9d6387e856c33d2ef8e8e9fdac0ac">cbor_new_indefinite_bytestring</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;    *item = (<a class="code" href="data_8h.html#afdaa4bcbbdd295d719e39ce0b5519419">cbor_item_t</a>) {</div><div class="line"><a name="l00050"></a><span class="lineno">   50</span>&#160;        .<a class="code" href="structcbor__item__t.html#a6bb24fe655f086c6aa9a66d427e09cca">refcount</a> = 1,</div><div class="line"><a name="l00051"></a><span class="lineno">   51</span>&#160;        .type = <a class="code" href="data_8h.html#a3a931b40fc31b51cccfd1bc3dc5fc5d6a70b9f0b5958c8d51f15ad7bb7c4af01d">CBOR_TYPE_BYTESTRING</a>,</div><div class="line"><a name="l00052"></a><span class="lineno">   52</span>&#160;        .metadata = {.bytestring_metadata = {.type = <a class="code" href="data_8h.html#a3cdab5e05cf46846e98b43cf77985589ae598476995d503b404ccf78c21ab79ef">_CBOR_METADATA_INDEFINITE</a>, .length = 0}},</div><div class="line"><a name="l00053"></a><span class="lineno">   53</span>&#160;        .data = <a class="code" href="common_8h.html#a07a781e9212fad361b0f59f7fc921057">_CBOR_MALLOC</a>(<span class="keyword">sizeof</span>(<span class="keyword">struct</span> <a class="code" href="structcbor__indefinite__string__data.html">cbor_indefinite_string_data</a>))</div><div class="line"><a name="l00054"></a><span class="lineno">   54</span>&#160;    };</div><div class="line"><a name="l00055"></a><span class="lineno">   55</span>&#160;    *((<span class="keyword">struct </span><a class="code" href="structcbor__indefinite__string__data.html">cbor_indefinite_string_data</a> *) item-&gt;<a class="code" href="structcbor__item__t.html#a5c6dde1dbef5aad748c49786352eef44">data</a>) = (<span class="keyword">struct </span><a class="code" href="structcbor__indefinite__string__data.html">cbor_indefinite_string_data</a>) {</div><div class="line"><a name="l00056"></a><span class="lineno">   56</span>&#160;        .chunk_count = 0,</div><div class="line"><a name="l00057"></a><span class="lineno">   57</span>&#160;        .chunk_capacity = 0,</div><div class="line"><a name="l00058"></a><span class="lineno">   58</span>&#160;        .chunks = NULL,</div><div class="line"><a name="l00059"></a><span class="lineno">   59</span>&#160;    };</div><div class="line"><a name="l00060"></a><span class="lineno">   60</span>&#160;    <span class="keywordflow">return</span> item;</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;</div><div class="line"><a name="l00063"></a><span class="lineno"><a class="line" href="bytestrings_8h.html#ab76bd5ff62831739cd9a8d7ec2768c1a">   63</a></span>&#160;<a class="code" href="structcbor__item__t.html">cbor_item_t</a> *<a class="code" href="bytestrings_8c.html#ab76bd5ff62831739cd9a8d7ec2768c1a">cbor_build_bytestring</a>(<a class="code" href="data_8h.html#a121c5944682215e742475f12f07c0a72">cbor_data</a> handle, <span class="keywordtype">size_t</span> length)</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;    <a class="code" href="structcbor__item__t.html">cbor_item_t</a> *res = <a class="code" href="bytestrings_8c.html#a86fc646f4520b90c85a704d27b46e69e">cbor_new_definite_bytestring</a>();</div><div class="line"><a name="l00066"></a><span class="lineno">   66</span>&#160;    <span class="keywordtype">void</span> * content = <a class="code" href="common_8h.html#a07a781e9212fad361b0f59f7fc921057">_CBOR_MALLOC</a>(length);</div><div class="line"><a name="l00067"></a><span class="lineno">   67</span>&#160;    memcpy(content, handle, length);</div><div class="line"><a name="l00068"></a><span class="lineno">   68</span>&#160;    <a class="code" href="bytestrings_8c.html#a513fd06374cb4faa9e909c85e4248199">cbor_bytestring_set_handle</a>(res, content, length);</div><div class="line"><a name="l00069"></a><span class="lineno">   69</span>&#160;    <span class="keywordflow">return</span> res;</div><div class="line"><a name="l00070"></a><span class="lineno">   70</span>&#160;}</div><div class="line"><a name="l00071"></a><span class="lineno">   71</span>&#160;</div><div class="line"><a name="l00072"></a><span class="lineno"><a class="line" href="bytestrings_8h.html#a513fd06374cb4faa9e909c85e4248199">   72</a></span>&#160;<span class="keywordtype">void</span> <a class="code" href="bytestrings_8c.html#a513fd06374cb4faa9e909c85e4248199">cbor_bytestring_set_handle</a>(<a class="code" href="structcbor__item__t.html">cbor_item_t</a> *item, <a class="code" href="data_8h.html#aabb40e458ece40477e134a69c76693e8">cbor_mutable_data</a> <a class="code" href="common_8h.html#a9ac79315ed2dcf2c9587e8e3a9a6bc97">CBOR_RESTRICT_POINTER</a> data, <span class="keywordtype">size_t</span> length)</div><div class="line"><a name="l00073"></a><span class="lineno">   73</span>&#160;{</div><div class="line"><a name="l00074"></a><span class="lineno">   74</span>&#160;    assert(<a class="code" href="common_8c.html#adedaf37527b8d8261e287a0001e5a190">cbor_isa_bytestring</a>(item));</div><div class="line"><a name="l00075"></a><span class="lineno">   75</span>&#160;    assert(<a class="code" href="bytestrings_8c.html#a368222dbbcea25e06469524e26587e2a">cbor_bytestring_is_definite</a>(item));</div><div class="line"><a name="l00076"></a><span class="lineno">   76</span>&#160;    item-&gt;<a class="code" href="structcbor__item__t.html#a5c6dde1dbef5aad748c49786352eef44">data</a> = data;</div><div class="line"><a name="l00077"></a><span class="lineno">   77</span>&#160;    item-&gt;<a class="code" href="structcbor__item__t.html#a7d97fa5cdf027ca0499c37ec19acf843">metadata</a>.<a class="code" href="unioncbor__item__metadata.html#a90851d347147760c9cef8d7af485d006">bytestring_metadata</a>.<a class="code" href="struct__cbor__bytestring__metadata.html#ad20fa7f7cec11db8076419169347ff75">length</a> = length;</div><div class="line"><a name="l00078"></a><span class="lineno">   78</span>&#160;}</div><div class="line"><a name="l00079"></a><span class="lineno">   79</span>&#160;</div><div class="line"><a name="l00080"></a><span class="lineno"><a class="line" href="bytestrings_8h.html#a8ab6255d6f8f209149bdf794dffed849">   80</a></span>&#160;<a class="code" href="structcbor__item__t.html">cbor_item_t</a> **<a class="code" href="bytestrings_8c.html#a8ab6255d6f8f209149bdf794dffed849">cbor_bytestring_chunks_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="l00081"></a><span class="lineno">   81</span>&#160;{</div><div class="line"><a name="l00082"></a><span class="lineno">   82</span>&#160;    assert(<a class="code" href="common_8c.html#adedaf37527b8d8261e287a0001e5a190">cbor_isa_bytestring</a>(item));</div><div class="line"><a name="l00083"></a><span class="lineno">   83</span>&#160;    assert(<a class="code" href="bytestrings_8c.html#a3a6c450f105bb18b6b56d20f0de4786a">cbor_bytestring_is_indefinite</a>(item));</div><div class="line"><a name="l00084"></a><span class="lineno">   84</span>&#160;    <span class="keywordflow">return</span> ((<span class="keyword">struct</span> <a class="code" href="structcbor__indefinite__string__data.html">cbor_indefinite_string_data</a> *) item-&gt;<a class="code" href="structcbor__item__t.html#a5c6dde1dbef5aad748c49786352eef44">data</a>)-&gt;chunks;</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"><a class="line" href="bytestrings_8h.html#ad02102832d452fd5a5cfa96272b1095d">   87</a></span>&#160;<span class="keywordtype">size_t</span> <a class="code" href="bytestrings_8c.html#ad02102832d452fd5a5cfa96272b1095d">cbor_bytestring_chunk_count</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="l00088"></a><span class="lineno">   88</span>&#160;{</div><div class="line"><a name="l00089"></a><span class="lineno">   89</span>&#160;    assert(<a class="code" href="common_8c.html#adedaf37527b8d8261e287a0001e5a190">cbor_isa_bytestring</a>(item));</div><div class="line"><a name="l00090"></a><span class="lineno">   90</span>&#160;    assert(<a class="code" href="bytestrings_8c.html#a3a6c450f105bb18b6b56d20f0de4786a">cbor_bytestring_is_indefinite</a>(item));</div><div class="line"><a name="l00091"></a><span class="lineno">   91</span>&#160;    <span class="keywordflow">return</span> ((<span class="keyword">struct</span> <a class="code" href="structcbor__indefinite__string__data.html">cbor_indefinite_string_data</a> *) item-&gt;<a class="code" href="structcbor__item__t.html#a5c6dde1dbef5aad748c49786352eef44">data</a>)-&gt;chunk_count;</div><div class="line"><a name="l00092"></a><span class="lineno">   92</span>&#160;</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"><a class="line" href="bytestrings_8h.html#a5dc8c27d6e7acfdd05fdc15c01e25b47">   95</a></span>&#160;<span class="keywordtype">bool</span> <a class="code" href="bytestrings_8c.html#a5dc8c27d6e7acfdd05fdc15c01e25b47">cbor_bytestring_add_chunk</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> *chunk)</div><div class="line"><a name="l00096"></a><span class="lineno">   96</span>&#160;{</div><div class="line"><a name="l00097"></a><span class="lineno">   97</span>&#160;    assert(<a class="code" href="common_8c.html#adedaf37527b8d8261e287a0001e5a190">cbor_isa_bytestring</a>(item));</div><div class="line"><a name="l00098"></a><span class="lineno">   98</span>&#160;    assert(<a class="code" href="bytestrings_8c.html#a3a6c450f105bb18b6b56d20f0de4786a">cbor_bytestring_is_indefinite</a>(item));</div><div class="line"><a name="l00099"></a><span class="lineno">   99</span>&#160;    <span class="keyword">struct </span><a class="code" href="structcbor__indefinite__string__data.html">cbor_indefinite_string_data</a> *data = (<span class="keyword">struct </span><a class="code" href="structcbor__indefinite__string__data.html">cbor_indefinite_string_data</a> *) item-&gt;<a class="code" href="structcbor__item__t.html#a5c6dde1dbef5aad748c49786352eef44">data</a>;</div><div class="line"><a name="l00100"></a><span class="lineno">  100</span>&#160;    if (data-&gt;<a class="code" href="structcbor__indefinite__string__data.html#a86c3abce37287c14985b5f2a0d1935d7">chunk_count</a> == data-&gt;<a class="code" href="structcbor__indefinite__string__data.html#a4f07710bcaa663d2babf652fc9984412">chunk_capacity</a>) {</div><div class="line"><a name="l00101"></a><span class="lineno">  101</span>&#160;        <span class="comment">/* We need more space */</span></div><div class="line"><a name="l00102"></a><span class="lineno">  102</span>&#160;        <span class="keywordflow">if</span> (!<a class="code" href="memory__utils_8c.html#abdee08be3f4cff35a94279fda66c4778">_cbor_safe_to_multiply</a>(CBOR_BUFFER_GROWTH, data-&gt;<a class="code" href="structcbor__indefinite__string__data.html#a4f07710bcaa663d2babf652fc9984412">chunk_capacity</a>)) {</div><div class="line"><a name="l00103"></a><span class="lineno">  103</span>&#160;            <span class="keywordflow">return</span> <span class="keyword">false</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">  106</span>&#160;        data-&gt;<a class="code" href="structcbor__indefinite__string__data.html#a4f07710bcaa663d2babf652fc9984412">chunk_capacity</a> = data-&gt;<a class="code" href="structcbor__indefinite__string__data.html#a4f07710bcaa663d2babf652fc9984412">chunk_capacity</a> == 0 ? 1 : CBOR_BUFFER_GROWTH * (data-&gt;<a class="code" href="structcbor__indefinite__string__data.html#a4f07710bcaa663d2babf652fc9984412">chunk_capacity</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;        <a class="code" href="structcbor__item__t.html">cbor_item_t</a> **new_chunks_data = <a class="code" href="memory__utils_8c.html#afd7a22ccd3b44d6ff668e14c3a006e40">_cbor_realloc_multiple</a>(data-&gt;<a class="code" href="structcbor__indefinite__string__data.html#ac34c0d9bd1447f53149878128e19a414">chunks</a>, <span class="keyword">sizeof</span>(<a class="code" href="structcbor__item__t.html">cbor_item_t</a> *), data-&gt;<a class="code" href="structcbor__indefinite__string__data.html#a4f07710bcaa663d2babf652fc9984412">chunk_capacity</a>);</div><div class="line"><a name="l00109"></a><span class="lineno">  109</span>&#160;</div><div class="line"><a name="l00110"></a><span class="lineno">  110</span>&#160;        <span class="keywordflow">if</span> (new_chunks_data == NULL) {</div><div class="line"><a name="l00111"></a><span class="lineno">  111</span>&#160;            <span class="keywordflow">return</span> <span class="keyword">false</span>;</div><div class="line"><a name="l00112"></a><span class="lineno">  112</span>&#160;        }</div><div class="line"><a name="l00113"></a><span class="lineno">  113</span>&#160;</div><div class="line"><a name="l00114"></a><span class="lineno">  114</span>&#160;        data-&gt;<a class="code" href="structcbor__indefinite__string__data.html#ac34c0d9bd1447f53149878128e19a414">chunks</a> = new_chunks_data;</div><div class="line"><a name="l00115"></a><span class="lineno">  115</span>&#160;    }</div><div class="line"><a name="l00116"></a><span class="lineno">  116</span>&#160;    data-&gt;<a class="code" href="structcbor__indefinite__string__data.html#ac34c0d9bd1447f53149878128e19a414">chunks</a>[data-&gt;<a class="code" href="structcbor__indefinite__string__data.html#a86c3abce37287c14985b5f2a0d1935d7">chunk_count</a>++] = <a class="code" href="common_8c.html#aa62e72f275c2f0fa604896bfed18e992">cbor_incref</a>(chunk);</div><div class="line"><a name="l00117"></a><span class="lineno">  117</span>&#160;    <span class="keywordflow">return</span> <span class="keyword">true</span>;</div><div class="line"><a name="l00118"></a><span class="lineno">  118</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="bytestrings_8c_html_a368222dbbcea25e06469524e26587e2a"><div class="ttname"><a href="bytestrings_8c.html#a368222dbbcea25e06469524e26587e2a">cbor_bytestring_is_definite</a></div><div class="ttdeci">bool cbor_bytestring_is_definite(const cbor_item_t *item)</div><div class="ttdoc">Is the byte string definite? </div><div class="ttdef"><b>Definition:</b> <a href="bytestrings_8c_source.html#l00024">bytestrings.c:24</a></div></div>
<div class="ttc" id="structcbor__indefinite__string__data_html_ac34c0d9bd1447f53149878128e19a414"><div class="ttname"><a href="structcbor__indefinite__string__data.html#ac34c0d9bd1447f53149878128e19a414">cbor_indefinite_string_data::chunks</a></div><div class="ttdeci">cbor_item_t ** chunks</div><div class="ttdef"><b>Definition:</b> <a href="data_8h_source.html#l00167">data.h:167</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="data_8h_html_a3a931b40fc31b51cccfd1bc3dc5fc5d6a70b9f0b5958c8d51f15ad7bb7c4af01d"><div class="ttname"><a href="data_8h.html#a3a931b40fc31b51cccfd1bc3dc5fc5d6a70b9f0b5958c8d51f15ad7bb7c4af01d">CBOR_TYPE_BYTESTRING</a></div><div class="ttdoc">2 - byte strings </div><div class="ttdef"><b>Definition:</b> <a href="data_8h_source.html#l00027">data.h:27</a></div></div>
<div class="ttc" id="bytestrings_8c_html_a6de9d6387e856c33d2ef8e8e9fdac0ac"><div class="ttname"><a href="bytestrings_8c.html#a6de9d6387e856c33d2ef8e8e9fdac0ac">cbor_new_indefinite_bytestring</a></div><div class="ttdeci">cbor_item_t * cbor_new_indefinite_bytestring()</div><div class="ttdoc">Creates a new indefinite byte string. </div><div class="ttdef"><b>Definition:</b> <a href="bytestrings_8c_source.html#l00046">bytestrings.c:46</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__indefinite__string__data_html_a86c3abce37287c14985b5f2a0d1935d7"><div class="ttname"><a href="structcbor__indefinite__string__data.html#a86c3abce37287c14985b5f2a0d1935d7">cbor_indefinite_string_data::chunk_count</a></div><div class="ttdeci">size_t chunk_count</div><div class="ttdef"><b>Definition:</b> <a href="data_8h_source.html#l00165">data.h:165</a></div></div>
<div class="ttc" id="bytestrings_8c_html_ad02102832d452fd5a5cfa96272b1095d"><div class="ttname"><a href="bytestrings_8c.html#ad02102832d452fd5a5cfa96272b1095d">cbor_bytestring_chunk_count</a></div><div class="ttdeci">size_t cbor_bytestring_chunk_count(const cbor_item_t *item)</div><div class="ttdoc">Get the number of chunks this string consist of. </div><div class="ttdef"><b>Definition:</b> <a href="bytestrings_8c_source.html#l00087">bytestrings.c:87</a></div></div>
<div class="ttc" id="bytestrings_8c_html_a86fc646f4520b90c85a704d27b46e69e"><div class="ttname"><a href="bytestrings_8c.html#a86fc646f4520b90c85a704d27b46e69e">cbor_new_definite_bytestring</a></div><div class="ttdeci">cbor_item_t * cbor_new_definite_bytestring()</div><div class="ttdoc">Creates a new definite byte string. </div><div class="ttdef"><b>Definition:</b> <a href="bytestrings_8c_source.html#l00035">bytestrings.c:35</a></div></div>
<div class="ttc" id="unioncbor__item__metadata_html_a90851d347147760c9cef8d7af485d006"><div class="ttname"><a href="unioncbor__item__metadata.html#a90851d347147760c9cef8d7af485d006">cbor_item_metadata::bytestring_metadata</a></div><div class="ttdeci">struct _cbor_bytestring_metadata bytestring_metadata</div><div class="ttdef"><b>Definition:</b> <a href="data_8h_source.html#l00140">data.h:140</a></div></div>
<div class="ttc" id="common_8c_html_adedaf37527b8d8261e287a0001e5a190"><div class="ttname"><a href="common_8c.html#adedaf37527b8d8261e287a0001e5a190">cbor_isa_bytestring</a></div><div class="ttdeci">bool cbor_isa_bytestring(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#l00028">common.c:28</a></div></div>
<div class="ttc" id="struct__cbor__bytestring__metadata_html_ab43be7eca10ef7f0501d9f87482e27c3"><div class="ttname"><a href="struct__cbor__bytestring__metadata.html#ab43be7eca10ef7f0501d9f87482e27c3">_cbor_bytestring_metadata::type</a></div><div class="ttdeci">_cbor_dst_metadata type</div><div class="ttdef"><b>Definition:</b> <a href="data_8h_source.html#l00084">data.h:84</a></div></div>
<div class="ttc" id="common_8h_html_a9ac79315ed2dcf2c9587e8e3a9a6bc97"><div class="ttname"><a href="common_8h.html#a9ac79315ed2dcf2c9587e8e3a9a6bc97">CBOR_RESTRICT_POINTER</a></div><div class="ttdeci">#define CBOR_RESTRICT_POINTER</div><div class="ttdef"><b>Definition:</b> <a href="common_8h_source.html#l00033">common.h:33</a></div></div>
<div class="ttc" id="bytestrings_8c_html_a8ab6255d6f8f209149bdf794dffed849"><div class="ttname"><a href="bytestrings_8c.html#a8ab6255d6f8f209149bdf794dffed849">cbor_bytestring_chunks_handle</a></div><div class="ttdeci">cbor_item_t ** cbor_bytestring_chunks_handle(const cbor_item_t *item)</div><div class="ttdoc">Get the handle to the array of chunks. </div><div class="ttdef"><b>Definition:</b> <a href="bytestrings_8c_source.html#l00080">bytestrings.c:80</a></div></div>
<div class="ttc" id="bytestrings_8c_html_a3a6c450f105bb18b6b56d20f0de4786a"><div class="ttname"><a href="bytestrings_8c.html#a3a6c450f105bb18b6b56d20f0de4786a">cbor_bytestring_is_indefinite</a></div><div class="ttdeci">bool cbor_bytestring_is_indefinite(const cbor_item_t *item)</div><div class="ttdoc">Is the byte string indefinite? </div><div class="ttdef"><b>Definition:</b> <a href="bytestrings_8c_source.html#l00030">bytestrings.c:30</a></div></div>
<div class="ttc" id="struct__cbor__bytestring__metadata_html_ad20fa7f7cec11db8076419169347ff75"><div class="ttname"><a href="struct__cbor__bytestring__metadata.html#ad20fa7f7cec11db8076419169347ff75">_cbor_bytestring_metadata::length</a></div><div class="ttdeci">size_t length</div><div class="ttdef"><b>Definition:</b> <a href="data_8h_source.html#l00083">data.h:83</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="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="structcbor__indefinite__string__data_html_a4f07710bcaa663d2babf652fc9984412"><div class="ttname"><a href="structcbor__indefinite__string__data.html#a4f07710bcaa663d2babf652fc9984412">cbor_indefinite_string_data::chunk_capacity</a></div><div class="ttdeci">size_t chunk_capacity</div><div class="ttdef"><b>Definition:</b> <a href="data_8h_source.html#l00166">data.h:166</a></div></div>
<div class="ttc" id="data_8h_html_aabb40e458ece40477e134a69c76693e8"><div class="ttname"><a href="data_8h.html#aabb40e458ece40477e134a69c76693e8">cbor_mutable_data</a></div><div class="ttdeci">unsigned char * cbor_mutable_data</div><div class="ttdef"><b>Definition:</b> <a href="data_8h_source.html#l00021">data.h:21</a></div></div>
<div class="ttc" id="bytestrings_8c_html_a5dc8c27d6e7acfdd05fdc15c01e25b47"><div class="ttname"><a href="bytestrings_8c.html#a5dc8c27d6e7acfdd05fdc15c01e25b47">cbor_bytestring_add_chunk</a></div><div class="ttdeci">bool cbor_bytestring_add_chunk(cbor_item_t *item, cbor_item_t *chunk)</div><div class="ttdoc">Appends a chunk to the bytestring. </div><div class="ttdef"><b>Definition:</b> <a href="bytestrings_8c_source.html#l00095">bytestrings.c:95</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="structcbor__indefinite__string__data_html"><div class="ttname"><a href="structcbor__indefinite__string__data.html">cbor_indefinite_string_data</a></div><div class="ttdoc">Defines cbor_item_t::data structure for indefinite strings and bytestrings. </div><div class="ttdef"><b>Definition:</b> <a href="data_8h_source.html#l00164">data.h:164</a></div></div>
<div class="ttc" id="data_8h_html_a121c5944682215e742475f12f07c0a72"><div class="ttname"><a href="data_8h.html#a121c5944682215e742475f12f07c0a72">cbor_data</a></div><div class="ttdeci">const unsigned char * cbor_data</div><div class="ttdef"><b>Definition:</b> <a href="data_8h_source.html#l00020">data.h:20</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="memory__utils_8h_html"><div class="ttname"><a href="memory__utils_8h.html">memory_utils.h</a></div></div>
<div class="ttc" id="bytestrings_8h_html"><div class="ttname"><a href="bytestrings_8h.html">bytestrings.h</a></div></div>
<div class="ttc" id="bytestrings_8c_html_a513fd06374cb4faa9e909c85e4248199"><div class="ttname"><a href="bytestrings_8c.html#a513fd06374cb4faa9e909c85e4248199">cbor_bytestring_set_handle</a></div><div class="ttdeci">void cbor_bytestring_set_handle(cbor_item_t *item, cbor_mutable_data CBOR_RESTRICT_POINTER data, size_t length)</div><div class="ttdoc">Set the handle to the binary data. </div><div class="ttdef"><b>Definition:</b> <a href="bytestrings_8c_source.html#l00072">bytestrings.c:72</a></div></div>
<div class="ttc" id="bytestrings_8c_html_a2c9d6feda3d0f87782168fa817f83be6"><div class="ttname"><a href="bytestrings_8c.html#a2c9d6feda3d0f87782168fa817f83be6">cbor_bytestring_handle</a></div><div class="ttdeci">unsigned char * cbor_bytestring_handle(const cbor_item_t *item)</div><div class="ttdoc">Get the handle to the binary data. </div><div class="ttdef"><b>Definition:</b> <a href="bytestrings_8c_source.html#l00018">bytestrings.c:18</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="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="bytestrings_8c_html_ab76bd5ff62831739cd9a8d7ec2768c1a"><div class="ttname"><a href="bytestrings_8c.html#ab76bd5ff62831739cd9a8d7ec2768c1a">cbor_build_bytestring</a></div><div class="ttdeci">cbor_item_t * cbor_build_bytestring(cbor_data handle, size_t length)</div><div class="ttdoc">Creates a new byte string and initializes it. </div><div class="ttdef"><b>Definition:</b> <a href="bytestrings_8c_source.html#l00063">bytestrings.c:63</a></div></div>
<div class="ttc" id="bytestrings_8c_html_a7c15a63fdc3830707eac0877a261f1cd"><div class="ttname"><a href="bytestrings_8c.html#a7c15a63fdc3830707eac0877a261f1cd">cbor_bytestring_length</a></div><div class="ttdeci">size_t cbor_bytestring_length(const cbor_item_t *item)</div><div class="ttdoc">Returns the length of the binary data. </div><div class="ttdef"><b>Definition:</b> <a href="bytestrings_8c_source.html#l00012">bytestrings.c:12</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>