123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170 |
- <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
- <html>
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
- <title><GByteArray>: </title>
- <meta name="generator" content="DocBook XSL Stylesheets V1.79.2">
- <link rel="home" href="index.html" title="">
- <link rel="up" href="ch01.html" title="GLib">
- <link rel="prev" href="re03.html" title="<%GLibBookmarkFileError>">
- <link rel="next" href="re05.html" title="<GBytes>">
- <meta name="generator" content="GTK-Doc V1.33.1 (XML mode)">
- <link rel="stylesheet" href="style.css" type="text/css">
- </head>
- <body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
- <table class="navigation" id="top" width="100%" summary="Navigation header" cellpadding="2" cellspacing="5"><tr valign="middle">
- <td width="100%" align="left" class="shortcuts"></td>
- <td><a accesskey="h" href="index.html"><img src="home.png" width="16" height="16" border="0" alt="Home"></a></td>
- <td><img src="up-insensitive.png" width="16" height="16" border="0"></td>
- <td><a accesskey="p" href="re03.html"><img src="left.png" width="16" height="16" border="0" alt="Prev"></a></td>
- <td><a accesskey="n" href="re05.html"><img src="right.png" width="16" height="16" border="0" alt="Next"></a></td>
- </tr></table>
- <div class="refentry">
- <a name="id-1.1.5"></a><div class="titlepage"></div>
- <div class="refnamediv">
- <h2><GByteArray></h2>
- <p><GByteArray></p>
- </div>
- <div class="refsect1">
- <a name="id-1.1.5.2"></a><h2>Description</h2>
- <p>Contains the public fields of a GByteArray.</p>
- </div>
- <div class="refsect1">
- <a name="id-1.1.5.3"></a><h2>Functions</h2>
- <div class="refsect2">
- <a name="id-1.1.5.3.2"></a><h3>byte-array:free</h3>
- <div class="informalexample"><pre class="programlisting">(define-values (%return) (byte-array:free array free-segment))
- </pre></div>
- <p>Frees the memory allocated by the <span class="type">GByteArray</span>. If <em class="parameter"><code>free_segment</code></em> is
- <code class="constant">TRUE</code> it frees the actual byte data. If the reference count of
- <em class="parameter"><code>array</code></em> is greater than one, the <span class="type">GByteArray</span> wrapper is preserved but
- the size of <em class="parameter"><code>array</code></em> will be set to zero.</p>
- <div class="refsect3">
- <a name="id-1.1.5.3.2.4"></a><h4>Parameters</h4>
- <div class="informaltable"><table>
- <tr>
- <td class="parameter_name"><p>array</p></td>
- <td class="parameter_description">
- <p>a <span class="type">GByteArray</span></p>
- <p>Passed as <code class="code">array</code></p>
- </td>
- </tr>
- <tr>
- <td class="parameter_name"><p>free_segment</p></td>
- <td class="parameter_description">
- <p>if <code class="constant">TRUE</code> the actual byte data is freed as well</p>
- <p>Passed as <code class="code">free-segment</code></p>
- </td>
- </tr>
- </table></div>
- </div>
- </div>
- <div class="refsect2">
- <a name="id-1.1.5.3.3"></a><h3>byte-array:free-to-bytes</h3>
- <div class="informalexample"><pre class="programlisting">(define-values (%return) (byte-array:free-to-bytes array))
- </pre></div>
- <p>Transfers the data from the <span class="type">GByteArray</span> into a new immutable <span class="type">GBytes</span>.
- </p>
- <p>The <span class="type">GByteArray</span> is freed unless the reference count of <em class="parameter"><code>array</code></em> is greater
- than one, the <span class="type">GByteArray</span> wrapper is preserved but the size of <em class="parameter"><code>array</code></em>
- will be set to zero.
- </p>
- <p>This is identical to using <code class="function">g_bytes_new_take()</code> and <code class="function">g_byte_array_free()</code>
- together.</p>
- <div class="refsect3">
- <a name="id-1.1.5.3.3.6"></a><h4>Parameters</h4>
- <div class="informaltable"><table><tr>
- <td class="parameter_name"><p>array</p></td>
- <td class="parameter_description">
- <p>a <span class="type">GByteArray</span></p>
- <p>Passed as <code class="code">array</code></p>
- </td>
- </tr></table></div>
- </div>
- </div>
- <div class="refsect2">
- <a name="id-1.1.5.3.4"></a><h3>byte-array:new</h3>
- <div class="informalexample"><pre class="programlisting">(define-values (%return) (byte-array:new))
- </pre></div>
- <p>Creates a new <span class="type">GByteArray</span> with a reference count of 1.</p>
- </div>
- <div class="refsect2">
- <a name="id-1.1.5.3.5"></a><h3>byte-array:new-take</h3>
- <div class="informalexample"><pre class="programlisting">(define-values (%return) (byte-array:new-take data))
- </pre></div>
- <p>Create byte array containing the data. The data will be owned by the array
- and will be freed with <code class="function">g_free()</code>, i.e. it could be allocated using <code class="function">g_strdup()</code>.</p>
- <div class="refsect3">
- <a name="id-1.1.5.3.5.4"></a><h4>Parameters</h4>
- <div class="informaltable"><table>
- <tr>
- <td class="parameter_name"><p>data</p></td>
- <td class="parameter_description">
- <p>byte data for the array</p>
- <p>Passed as <code class="code">data</code></p>
- </td>
- </tr>
- <tr>
- <td class="parameter_name"><p>len</p></td>
- <td class="parameter_description">
- <p>length of <em class="parameter"><code>data</code></em></p>
- <p>Inferred from <code class="code">data</code></p>
- </td>
- </tr>
- </table></div>
- </div>
- </div>
- <div class="refsect2">
- <a name="id-1.1.5.3.6"></a><h3>byte-array:steal</h3>
- <div class="informalexample"><pre class="programlisting">(define-values (%return len) (byte-array:steal array len))
- </pre></div>
- <p>Frees the data in the array and resets the size to zero, while
- the underlying array is preserved for use elsewhere and returned
- to the caller.</p>
- <div class="refsect3">
- <a name="id-1.1.5.3.6.4"></a><h4>Parameters</h4>
- <div class="informaltable"><table>
- <tr>
- <td class="parameter_name"><p>array</p></td>
- <td class="parameter_description">
- <p>a <span class="type">GByteArray</span>.</p>
- <p>Passed as <code class="code">array</code></p>
- </td>
- </tr>
- <tr>
- <td class="parameter_name"><p>len</p></td>
- <td class="parameter_description">
- <p>pointer to retrieve the number of
- elements of the original array</p>
- <p>Passed as <code class="code">len</code></p>
- </td>
- </tr>
- </table></div>
- </div>
- </div>
- <div class="refsect2">
- <a name="id-1.1.5.3.7"></a><h3>byte-array:unref</h3>
- <div class="informalexample"><pre class="programlisting">(define-values () (byte-array:unref array))
- </pre></div>
- <p>Atomically decrements the reference count of <em class="parameter"><code>array</code></em> by one. If the
- reference count drops to 0, all memory allocated by the array is
- released. This function is thread-safe and may be called from any
- thread.</p>
- <div class="refsect3">
- <a name="id-1.1.5.3.7.4"></a><h4>Parameters</h4>
- <div class="informaltable"><table><tr>
- <td class="parameter_name"><p>array</p></td>
- <td class="parameter_description">
- <p>A <span class="type">GByteArray</span></p>
- <p>Passed as <code class="code">array</code></p>
- </td>
- </tr></table></div>
- </div>
- </div>
- </div>
- </div>
- <div class="footer">
- <hr>Generated by GTK-Doc V1.33.1</div>
- </body>
- </html>
|