<?xml version="1.0"?>
<!DOCTYPE refentry PUBLIC '-//OASIS//DTD DocBook XML V4.5//EN'
                      'http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd' [
<!ENTITY % local.common.attrib "xmlns:xi  CDATA  #FIXED 'http://www.w3.org/2003/XInclude'">
<!ENTITY version SYSTEM "version.xml">
]>
<refentry id="glib-Byte-Arrays">
<refmeta>
<refentrytitle role="top_of_page" id="glib-Byte-Arrays.top_of_page">Byte Arrays</refentrytitle>
<manvolnum>3</manvolnum>
<refmiscinfo>GLIB Library</refmiscinfo>
</refmeta>
<refnamediv>
<refname>Byte Arrays</refname>
<refpurpose>arrays of bytes</refpurpose>
</refnamediv>

<refsect1 id="glib-Byte-Arrays.functions" role="functions_proto">
<title role="functions_proto.title">Functions</title>
<informaltable pgwide="1" frame="none">
<tgroup cols="2">
<colspec colname="functions_proto_type" colwidth="150px"/>
<colspec colname="functions_proto_name"/>
<tbody>
<row><entry role="function_type"><link linkend="GByteArray"><returnvalue>GByteArray</returnvalue></link>&#160;*
</entry><entry role="function_name"><link linkend="g-byte-array-new">g_byte_array_new</link>&#160;<phrase role="c_punctuation">()</phrase></entry></row>
<row><entry role="function_type"><link linkend="GByteArray"><returnvalue>GByteArray</returnvalue></link>&#160;*
</entry><entry role="function_name"><link linkend="g-byte-array-new-take">g_byte_array_new_take</link>&#160;<phrase role="c_punctuation">()</phrase></entry></row>
<row><entry role="function_type"><link linkend="GByteArray"><returnvalue>GByteArray</returnvalue></link>&#160;*
</entry><entry role="function_name"><link linkend="g-byte-array-sized-new">g_byte_array_sized_new</link>&#160;<phrase role="c_punctuation">()</phrase></entry></row>
<row><entry role="function_type"><link linkend="GByteArray"><returnvalue>GByteArray</returnvalue></link>&#160;*
</entry><entry role="function_name"><link linkend="g-byte-array-ref">g_byte_array_ref</link>&#160;<phrase role="c_punctuation">()</phrase></entry></row>
<row><entry role="function_type"><link linkend="void"><returnvalue>void</returnvalue></link>
</entry><entry role="function_name"><link linkend="g-byte-array-unref">g_byte_array_unref</link>&#160;<phrase role="c_punctuation">()</phrase></entry></row>
<row><entry role="function_type"><link linkend="GByteArray"><returnvalue>GByteArray</returnvalue></link>&#160;*
</entry><entry role="function_name"><link linkend="g-byte-array-append">g_byte_array_append</link>&#160;<phrase role="c_punctuation">()</phrase></entry></row>
<row><entry role="function_type"><link linkend="GByteArray"><returnvalue>GByteArray</returnvalue></link>&#160;*
</entry><entry role="function_name"><link linkend="g-byte-array-prepend">g_byte_array_prepend</link>&#160;<phrase role="c_punctuation">()</phrase></entry></row>
<row><entry role="function_type"><link linkend="GByteArray"><returnvalue>GByteArray</returnvalue></link>&#160;*
</entry><entry role="function_name"><link linkend="g-byte-array-remove-index">g_byte_array_remove_index</link>&#160;<phrase role="c_punctuation">()</phrase></entry></row>
<row><entry role="function_type"><link linkend="GByteArray"><returnvalue>GByteArray</returnvalue></link>&#160;*
</entry><entry role="function_name"><link linkend="g-byte-array-remove-index-fast">g_byte_array_remove_index_fast</link>&#160;<phrase role="c_punctuation">()</phrase></entry></row>
<row><entry role="function_type"><link linkend="GByteArray"><returnvalue>GByteArray</returnvalue></link>&#160;*
</entry><entry role="function_name"><link linkend="g-byte-array-remove-range">g_byte_array_remove_range</link>&#160;<phrase role="c_punctuation">()</phrase></entry></row>
<row><entry role="function_type"><link linkend="void"><returnvalue>void</returnvalue></link>
</entry><entry role="function_name"><link linkend="g-byte-array-sort">g_byte_array_sort</link>&#160;<phrase role="c_punctuation">()</phrase></entry></row>
<row><entry role="function_type"><link linkend="void"><returnvalue>void</returnvalue></link>
</entry><entry role="function_name"><link linkend="g-byte-array-sort-with-data">g_byte_array_sort_with_data</link>&#160;<phrase role="c_punctuation">()</phrase></entry></row>
<row><entry role="function_type"><link linkend="GByteArray"><returnvalue>GByteArray</returnvalue></link>&#160;*
</entry><entry role="function_name"><link linkend="g-byte-array-set-size">g_byte_array_set_size</link>&#160;<phrase role="c_punctuation">()</phrase></entry></row>
<row><entry role="function_type"><link linkend="guint8"><returnvalue>guint8</returnvalue></link>&#160;*
</entry><entry role="function_name"><link linkend="g-byte-array-free">g_byte_array_free</link>&#160;<phrase role="c_punctuation">()</phrase></entry></row>
<row><entry role="function_type"><link linkend="GBytes"><returnvalue>GBytes</returnvalue></link>&#160;*
</entry><entry role="function_name"><link linkend="g-byte-array-free-to-bytes">g_byte_array_free_to_bytes</link>&#160;<phrase role="c_punctuation">()</phrase></entry></row>

<row><entry role="function_type"><link linkend="GBytes"><returnvalue>GBytes</returnvalue></link>&#160;*
</entry><entry role="function_name"><link linkend="g-bytes-new">g_bytes_new</link>&#160;<phrase role="c_punctuation">()</phrase></entry></row>
<row><entry role="function_type"><link linkend="GBytes"><returnvalue>GBytes</returnvalue></link>&#160;*
</entry><entry role="function_name"><link linkend="g-bytes-new-take">g_bytes_new_take</link>&#160;<phrase role="c_punctuation">()</phrase></entry></row>
<row><entry role="function_type"><link linkend="GBytes"><returnvalue>GBytes</returnvalue></link>&#160;*
</entry><entry role="function_name"><link linkend="g-bytes-new-static">g_bytes_new_static</link>&#160;<phrase role="c_punctuation">()</phrase></entry></row>
<row><entry role="function_type"><link linkend="GBytes"><returnvalue>GBytes</returnvalue></link>&#160;*
</entry><entry role="function_name"><link linkend="g-bytes-new-with-free-func">g_bytes_new_with_free_func</link>&#160;<phrase role="c_punctuation">()</phrase></entry></row>
<row><entry role="function_type"><link linkend="GBytes"><returnvalue>GBytes</returnvalue></link>&#160;*
</entry><entry role="function_name"><link linkend="g-bytes-new-from-bytes">g_bytes_new_from_bytes</link>&#160;<phrase role="c_punctuation">()</phrase></entry></row>
<row><entry role="function_type"><link linkend="gconstpointer"><returnvalue>gconstpointer</returnvalue></link>
</entry><entry role="function_name"><link linkend="g-bytes-get-data">g_bytes_get_data</link>&#160;<phrase role="c_punctuation">()</phrase></entry></row>
<row><entry role="function_type"><link linkend="gsize"><returnvalue>gsize</returnvalue></link>
</entry><entry role="function_name"><link linkend="g-bytes-get-size">g_bytes_get_size</link>&#160;<phrase role="c_punctuation">()</phrase></entry></row>
<row><entry role="function_type"><link linkend="guint"><returnvalue>guint</returnvalue></link>
</entry><entry role="function_name"><link linkend="g-bytes-hash">g_bytes_hash</link>&#160;<phrase role="c_punctuation">()</phrase></entry></row>
<row><entry role="function_type"><link linkend="gboolean"><returnvalue>gboolean</returnvalue></link>
</entry><entry role="function_name"><link linkend="g-bytes-equal">g_bytes_equal</link>&#160;<phrase role="c_punctuation">()</phrase></entry></row>
<row><entry role="function_type"><link linkend="gint"><returnvalue>gint</returnvalue></link>
</entry><entry role="function_name"><link linkend="g-bytes-compare">g_bytes_compare</link>&#160;<phrase role="c_punctuation">()</phrase></entry></row>
<row><entry role="function_type"><link linkend="GBytes"><returnvalue>GBytes</returnvalue></link>&#160;*
</entry><entry role="function_name"><link linkend="g-bytes-ref">g_bytes_ref</link>&#160;<phrase role="c_punctuation">()</phrase></entry></row>
<row><entry role="function_type"><link linkend="void"><returnvalue>void</returnvalue></link>
</entry><entry role="function_name"><link linkend="g-bytes-unref">g_bytes_unref</link>&#160;<phrase role="c_punctuation">()</phrase></entry></row>
<row><entry role="function_type"><link linkend="gpointer"><returnvalue>gpointer</returnvalue></link>
</entry><entry role="function_name"><link linkend="g-bytes-unref-to-data">g_bytes_unref_to_data</link>&#160;<phrase role="c_punctuation">()</phrase></entry></row>
<row><entry role="function_type"><link linkend="GByteArray"><returnvalue>GByteArray</returnvalue></link>&#160;*
</entry><entry role="function_name"><link linkend="g-bytes-unref-to-array">g_bytes_unref_to_array</link>&#160;<phrase role="c_punctuation">()</phrase></entry></row>

</tbody>
</tgroup>
</informaltable>
</refsect1>
<refsect1 id="glib-Byte-Arrays.other" role="other_proto">
<title role="other_proto.title">Types and Values</title>
<informaltable pgwide="1" frame="none">
<tgroup cols="2">
<colspec colname="other_proto_type" colwidth="150px"/>
<colspec colname="other_proto_name"/>
<tbody>
<row><entry role="datatype_keyword">struct</entry><entry role="function_name"><link linkend="GByteArray">GByteArray</link></entry></row>

<row><entry role="datatype_keyword"></entry><entry role="function_name"><link linkend="GBytes">GBytes</link></entry></row>

</tbody>
</tgroup>
</informaltable>
</refsect1>

<refsect1 id="glib-Byte-Arrays.includes"><title>Includes</title><synopsis>#include &lt;gmodule.h&gt;
</synopsis></refsect1>

<refsect1 id="glib-Byte-Arrays.description" role="desc">
<title role="desc.title">Description</title>
<para><link linkend="GByteArray"><type>GByteArray</type></link> is a mutable array of bytes based on <link linkend="GArray"><type>GArray</type></link>, to provide arrays
of bytes which grow automatically as elements are added.</para>
<para>To create a new <link linkend="GByteArray"><type>GByteArray</type></link> use <link linkend="g-byte-array-new"><function>g_byte_array_new()</function></link>. To add elements to a
<link linkend="GByteArray"><type>GByteArray</type></link>, use <link linkend="g-byte-array-append"><function>g_byte_array_append()</function></link>, and <link linkend="g-byte-array-prepend"><function>g_byte_array_prepend()</function></link>.</para>
<para>To set the size of a <link linkend="GByteArray"><type>GByteArray</type></link>, use <link linkend="g-byte-array-set-size"><function>g_byte_array_set_size()</function></link>.</para>
<para>To free a <link linkend="GByteArray"><type>GByteArray</type></link>, use <link linkend="g-byte-array-free"><function>g_byte_array_free()</function></link>.</para>
<para>An example for using a <link linkend="GByteArray"><type>GByteArray</type></link>:</para>
<informalexample><programlisting role="example"><![CDATA[
  GByteArray *gbarray;
  gint i;

  gbarray = g_byte_array_new ();
  for (i = 0; i < 10000; i++)
    g_byte_array_append (gbarray, (guint8*) "abcd", 4);

  for (i = 0; i < 10000; i++)
    {
      g_assert (gbarray->data[4*i] == 'a');
      g_assert (gbarray->data[4*i+1] == 'b');
      g_assert (gbarray->data[4*i+2] == 'c');
      g_assert (gbarray->data[4*i+3] == 'd');
    }

  g_byte_array_free (gbarray, TRUE);
]]></programlisting></informalexample>
<para></para>
<para>See <link linkend="GBytes"><type>GBytes</type></link> if you are interested in an immutable object representing a
sequence of bytes.</para>

</refsect1>
<refsect1 id="glib-Byte-Arrays.functions_details" role="details">
<title role="details.title">Functions</title>
<refsect2 id="g-byte-array-new" role="function">
<title>g_byte_array_new&#160;()</title>
<indexterm zone="g-byte-array-new"><primary sortas="byte_array_new">g_byte_array_new</primary></indexterm>
<programlisting language="C"><link linkend="GByteArray"><returnvalue>GByteArray</returnvalue></link>&#160;*
g_byte_array_new (<parameter><type>void</type></parameter>);</programlisting>
<para>Creates a new <link linkend="GByteArray"><type>GByteArray</type></link> with a reference count of 1.</para>
<refsect3 id="g-byte-array-new.returns" role="returns">
<title>Returns</title>
<para>the new <link linkend="GByteArray"><type>GByteArray</type></link>. </para>
<para><emphasis role="annotation">[<acronym>transfer full</acronym>]</emphasis></para>
</refsect3></refsect2>
<refsect2 id="g-byte-array-new-take" role="function" condition="since:2.32">
<title>g_byte_array_new_take&#160;()</title>
<indexterm zone="g-byte-array-new-take" role="2.32"><primary sortas="byte_array_new_take">g_byte_array_new_take</primary></indexterm>
<programlisting language="C"><link linkend="GByteArray"><returnvalue>GByteArray</returnvalue></link>&#160;*
g_byte_array_new_take (<parameter><link linkend="guint8"><type>guint8</type></link> *data</parameter>,
                       <parameter><link linkend="gsize"><type>gsize</type></link> len</parameter>);</programlisting>
<para>Create byte array containing the data. The data will be owned by the array
and will be freed with <link linkend="g-free"><function>g_free()</function></link>, i.e. it could be allocated using <link linkend="g-strdup"><function>g_strdup()</function></link>.</para>
<refsect3 id="g-byte-array-new-take.parameters" role="parameters">
<title>Parameters</title>
<informaltable role="parameters_table" pgwide="1" frame="none">
<tgroup cols="3">
<colspec colname="parameters_name" colwidth="150px"/>
<colspec colname="parameters_description"/>
<colspec colname="parameters_annotations" colwidth="200px"/>
<tbody>
<row><entry role="parameter_name"><para>data</para></entry>
<entry role="parameter_description"><para>byte data for the array. </para></entry>
<entry role="parameter_annotations"><emphasis role="annotation">[<acronym>transfer full</acronym>][<acronym>array</acronym> length=len]</emphasis></entry></row>
<row><entry role="parameter_name"><para>len</para></entry>
<entry role="parameter_description"><para>length of <parameter>data</parameter>
</para></entry>
<entry role="parameter_annotations"></entry></row>
</tbody></tgroup></informaltable>
</refsect3><refsect3 id="g-byte-array-new-take.returns" role="returns">
<title>Returns</title>
<para>a new <link linkend="GByteArray"><type>GByteArray</type></link>. </para>
<para><emphasis role="annotation">[<acronym>transfer full</acronym>]</emphasis></para>
</refsect3><para role="since">Since: <link linkend="api-index-2.32">2.32</link></para></refsect2>
<refsect2 id="g-byte-array-sized-new" role="function">
<title>g_byte_array_sized_new&#160;()</title>
<indexterm zone="g-byte-array-sized-new"><primary sortas="byte_array_sized_new">g_byte_array_sized_new</primary></indexterm>
<programlisting language="C"><link linkend="GByteArray"><returnvalue>GByteArray</returnvalue></link>&#160;*
g_byte_array_sized_new (<parameter><link linkend="guint"><type>guint</type></link> reserved_size</parameter>);</programlisting>
<para>Creates a new <link linkend="GByteArray"><type>GByteArray</type></link> with <parameter>reserved_size</parameter>
 bytes preallocated.
This avoids frequent reallocation, if you are going to add many
bytes to the array. Note however that the size of the array is still
0.</para>
<refsect3 id="g-byte-array-sized-new.parameters" role="parameters">
<title>Parameters</title>
<informaltable role="parameters_table" pgwide="1" frame="none">
<tgroup cols="3">
<colspec colname="parameters_name" colwidth="150px"/>
<colspec colname="parameters_description"/>
<colspec colname="parameters_annotations" colwidth="200px"/>
<tbody>
<row><entry role="parameter_name"><para>reserved_size</para></entry>
<entry role="parameter_description"><para>number of bytes preallocated</para></entry>
<entry role="parameter_annotations"></entry></row>
</tbody></tgroup></informaltable>
</refsect3><refsect3 id="g-byte-array-sized-new.returns" role="returns">
<title>Returns</title>
<para> the new <link linkend="GByteArray"><type>GByteArray</type></link></para>
</refsect3></refsect2>
<refsect2 id="g-byte-array-ref" role="function" condition="since:2.22">
<title>g_byte_array_ref&#160;()</title>
<indexterm zone="g-byte-array-ref" role="2.22"><primary sortas="byte_array_ref">g_byte_array_ref</primary></indexterm>
<programlisting language="C"><link linkend="GByteArray"><returnvalue>GByteArray</returnvalue></link>&#160;*
g_byte_array_ref (<parameter><link linkend="GByteArray"><type>GByteArray</type></link> *array</parameter>);</programlisting>
<para>Atomically increments the reference count of <parameter>array</parameter>
 by one.
This function is thread-safe and may be called from any thread.</para>
<refsect3 id="g-byte-array-ref.parameters" role="parameters">
<title>Parameters</title>
<informaltable role="parameters_table" pgwide="1" frame="none">
<tgroup cols="3">
<colspec colname="parameters_name" colwidth="150px"/>
<colspec colname="parameters_description"/>
<colspec colname="parameters_annotations" colwidth="200px"/>
<tbody>
<row><entry role="parameter_name"><para>array</para></entry>
<entry role="parameter_description"><para>A <link linkend="GByteArray"><type>GByteArray</type></link></para></entry>
<entry role="parameter_annotations"></entry></row>
</tbody></tgroup></informaltable>
</refsect3><refsect3 id="g-byte-array-ref.returns" role="returns">
<title>Returns</title>
<para> The passed in <link linkend="GByteArray"><type>GByteArray</type></link></para>
</refsect3><para role="since">Since: <link linkend="api-index-2.22">2.22</link></para></refsect2>
<refsect2 id="g-byte-array-unref" role="function" condition="since:2.22">
<title>g_byte_array_unref&#160;()</title>
<indexterm zone="g-byte-array-unref" role="2.22"><primary sortas="byte_array_unref">g_byte_array_unref</primary></indexterm>
<programlisting language="C"><link linkend="void"><returnvalue>void</returnvalue></link>
g_byte_array_unref (<parameter><link linkend="GByteArray"><type>GByteArray</type></link> *array</parameter>);</programlisting>
<para>Atomically decrements the reference count of <parameter>array</parameter>
 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.</para>
<refsect3 id="g-byte-array-unref.parameters" role="parameters">
<title>Parameters</title>
<informaltable role="parameters_table" pgwide="1" frame="none">
<tgroup cols="3">
<colspec colname="parameters_name" colwidth="150px"/>
<colspec colname="parameters_description"/>
<colspec colname="parameters_annotations" colwidth="200px"/>
<tbody>
<row><entry role="parameter_name"><para>array</para></entry>
<entry role="parameter_description"><para>A <link linkend="GByteArray"><type>GByteArray</type></link></para></entry>
<entry role="parameter_annotations"></entry></row>
</tbody></tgroup></informaltable>
</refsect3><para role="since">Since: <link linkend="api-index-2.22">2.22</link></para></refsect2>
<refsect2 id="g-byte-array-append" role="function">
<title>g_byte_array_append&#160;()</title>
<indexterm zone="g-byte-array-append"><primary sortas="byte_array_append">g_byte_array_append</primary></indexterm>
<programlisting language="C"><link linkend="GByteArray"><returnvalue>GByteArray</returnvalue></link>&#160;*
g_byte_array_append (<parameter><link linkend="GByteArray"><type>GByteArray</type></link> *array</parameter>,
                     <parameter>const <link linkend="guint8"><type>guint8</type></link> *data</parameter>,
                     <parameter><link linkend="guint"><type>guint</type></link> len</parameter>);</programlisting>
<para>Adds the given bytes to the end of the <link linkend="GByteArray"><type>GByteArray</type></link>.
The array will grow in size automatically if necessary.</para>
<refsect3 id="g-byte-array-append.parameters" role="parameters">
<title>Parameters</title>
<informaltable role="parameters_table" pgwide="1" frame="none">
<tgroup cols="3">
<colspec colname="parameters_name" colwidth="150px"/>
<colspec colname="parameters_description"/>
<colspec colname="parameters_annotations" colwidth="200px"/>
<tbody>
<row><entry role="parameter_name"><para>array</para></entry>
<entry role="parameter_description"><para>a <link linkend="GByteArray"><type>GByteArray</type></link></para></entry>
<entry role="parameter_annotations"></entry></row>
<row><entry role="parameter_name"><para>data</para></entry>
<entry role="parameter_description"><para>the byte data to be added</para></entry>
<entry role="parameter_annotations"></entry></row>
<row><entry role="parameter_name"><para>len</para></entry>
<entry role="parameter_description"><para>the number of bytes to add</para></entry>
<entry role="parameter_annotations"></entry></row>
</tbody></tgroup></informaltable>
</refsect3><refsect3 id="g-byte-array-append.returns" role="returns">
<title>Returns</title>
<para> the <link linkend="GByteArray"><type>GByteArray</type></link></para>
</refsect3></refsect2>
<refsect2 id="g-byte-array-prepend" role="function">
<title>g_byte_array_prepend&#160;()</title>
<indexterm zone="g-byte-array-prepend"><primary sortas="byte_array_prepend">g_byte_array_prepend</primary></indexterm>
<programlisting language="C"><link linkend="GByteArray"><returnvalue>GByteArray</returnvalue></link>&#160;*
g_byte_array_prepend (<parameter><link linkend="GByteArray"><type>GByteArray</type></link> *array</parameter>,
                      <parameter>const <link linkend="guint8"><type>guint8</type></link> *data</parameter>,
                      <parameter><link linkend="guint"><type>guint</type></link> len</parameter>);</programlisting>
<para>Adds the given data to the start of the <link linkend="GByteArray"><type>GByteArray</type></link>.
The array will grow in size automatically if necessary.</para>
<refsect3 id="g-byte-array-prepend.parameters" role="parameters">
<title>Parameters</title>
<informaltable role="parameters_table" pgwide="1" frame="none">
<tgroup cols="3">
<colspec colname="parameters_name" colwidth="150px"/>
<colspec colname="parameters_description"/>
<colspec colname="parameters_annotations" colwidth="200px"/>
<tbody>
<row><entry role="parameter_name"><para>array</para></entry>
<entry role="parameter_description"><para>a <link linkend="GByteArray"><type>GByteArray</type></link></para></entry>
<entry role="parameter_annotations"></entry></row>
<row><entry role="parameter_name"><para>data</para></entry>
<entry role="parameter_description"><para>the byte data to be added</para></entry>
<entry role="parameter_annotations"></entry></row>
<row><entry role="parameter_name"><para>len</para></entry>
<entry role="parameter_description"><para>the number of bytes to add</para></entry>
<entry role="parameter_annotations"></entry></row>
</tbody></tgroup></informaltable>
</refsect3><refsect3 id="g-byte-array-prepend.returns" role="returns">
<title>Returns</title>
<para> the <link linkend="GByteArray"><type>GByteArray</type></link></para>
</refsect3></refsect2>
<refsect2 id="g-byte-array-remove-index" role="function">
<title>g_byte_array_remove_index&#160;()</title>
<indexterm zone="g-byte-array-remove-index"><primary sortas="byte_array_remove_index">g_byte_array_remove_index</primary></indexterm>
<programlisting language="C"><link linkend="GByteArray"><returnvalue>GByteArray</returnvalue></link>&#160;*
g_byte_array_remove_index (<parameter><link linkend="GByteArray"><type>GByteArray</type></link> *array</parameter>,
                           <parameter><link linkend="guint"><type>guint</type></link> index_</parameter>);</programlisting>
<para>Removes the byte at the given index from a <link linkend="GByteArray"><type>GByteArray</type></link>.
The following bytes are moved down one place.</para>
<refsect3 id="g-byte-array-remove-index.parameters" role="parameters">
<title>Parameters</title>
<informaltable role="parameters_table" pgwide="1" frame="none">
<tgroup cols="3">
<colspec colname="parameters_name" colwidth="150px"/>
<colspec colname="parameters_description"/>
<colspec colname="parameters_annotations" colwidth="200px"/>
<tbody>
<row><entry role="parameter_name"><para>array</para></entry>
<entry role="parameter_description"><para>a <link linkend="GByteArray"><type>GByteArray</type></link></para></entry>
<entry role="parameter_annotations"></entry></row>
<row><entry role="parameter_name"><para>index_</para></entry>
<entry role="parameter_description"><para>the index of the byte to remove</para></entry>
<entry role="parameter_annotations"></entry></row>
</tbody></tgroup></informaltable>
</refsect3><refsect3 id="g-byte-array-remove-index.returns" role="returns">
<title>Returns</title>
<para> the <link linkend="GByteArray"><type>GByteArray</type></link></para>
</refsect3></refsect2>
<refsect2 id="g-byte-array-remove-index-fast" role="function">
<title>g_byte_array_remove_index_fast&#160;()</title>
<indexterm zone="g-byte-array-remove-index-fast"><primary sortas="byte_array_remove_index_fast">g_byte_array_remove_index_fast</primary></indexterm>
<programlisting language="C"><link linkend="GByteArray"><returnvalue>GByteArray</returnvalue></link>&#160;*
g_byte_array_remove_index_fast (<parameter><link linkend="GByteArray"><type>GByteArray</type></link> *array</parameter>,
                                <parameter><link linkend="guint"><type>guint</type></link> index_</parameter>);</programlisting>
<para>Removes the byte at the given index from a <link linkend="GByteArray"><type>GByteArray</type></link>. The last
element in the array is used to fill in the space, so this function
does not preserve the order of the <link linkend="GByteArray"><type>GByteArray</type></link>. But it is faster
than <link linkend="g-byte-array-remove-index"><function>g_byte_array_remove_index()</function></link>.</para>
<refsect3 id="g-byte-array-remove-index-fast.parameters" role="parameters">
<title>Parameters</title>
<informaltable role="parameters_table" pgwide="1" frame="none">
<tgroup cols="3">
<colspec colname="parameters_name" colwidth="150px"/>
<colspec colname="parameters_description"/>
<colspec colname="parameters_annotations" colwidth="200px"/>
<tbody>
<row><entry role="parameter_name"><para>array</para></entry>
<entry role="parameter_description"><para>a <link linkend="GByteArray"><type>GByteArray</type></link></para></entry>
<entry role="parameter_annotations"></entry></row>
<row><entry role="parameter_name"><para>index_</para></entry>
<entry role="parameter_description"><para>the index of the byte to remove</para></entry>
<entry role="parameter_annotations"></entry></row>
</tbody></tgroup></informaltable>
</refsect3><refsect3 id="g-byte-array-remove-index-fast.returns" role="returns">
<title>Returns</title>
<para> the <link linkend="GByteArray"><type>GByteArray</type></link></para>
</refsect3></refsect2>
<refsect2 id="g-byte-array-remove-range" role="function" condition="since:2.4">
<title>g_byte_array_remove_range&#160;()</title>
<indexterm zone="g-byte-array-remove-range" role="2.4"><primary sortas="byte_array_remove_range">g_byte_array_remove_range</primary></indexterm>
<programlisting language="C"><link linkend="GByteArray"><returnvalue>GByteArray</returnvalue></link>&#160;*
g_byte_array_remove_range (<parameter><link linkend="GByteArray"><type>GByteArray</type></link> *array</parameter>,
                           <parameter><link linkend="guint"><type>guint</type></link> index_</parameter>,
                           <parameter><link linkend="guint"><type>guint</type></link> length</parameter>);</programlisting>
<para>Removes the given number of bytes starting at the given index from a
<link linkend="GByteArray"><type>GByteArray</type></link>.  The following elements are moved to close the gap.</para>
<refsect3 id="g-byte-array-remove-range.parameters" role="parameters">
<title>Parameters</title>
<informaltable role="parameters_table" pgwide="1" frame="none">
<tgroup cols="3">
<colspec colname="parameters_name" colwidth="150px"/>
<colspec colname="parameters_description"/>
<colspec colname="parameters_annotations" colwidth="200px"/>
<tbody>
<row><entry role="parameter_name"><para>array</para></entry>
<entry role="parameter_description"><para>a <parameter>GByteArray</parameter>
</para></entry>
<entry role="parameter_annotations"></entry></row>
<row><entry role="parameter_name"><para>index_</para></entry>
<entry role="parameter_description"><para>the index of the first byte to remove</para></entry>
<entry role="parameter_annotations"></entry></row>
<row><entry role="parameter_name"><para>length</para></entry>
<entry role="parameter_description"><para>the number of bytes to remove</para></entry>
<entry role="parameter_annotations"></entry></row>
</tbody></tgroup></informaltable>
</refsect3><refsect3 id="g-byte-array-remove-range.returns" role="returns">
<title>Returns</title>
<para> the <link linkend="GByteArray"><type>GByteArray</type></link></para>
</refsect3><para role="since">Since: <link linkend="api-index-2.4">2.4</link></para></refsect2>
<refsect2 id="g-byte-array-sort" role="function">
<title>g_byte_array_sort&#160;()</title>
<indexterm zone="g-byte-array-sort"><primary sortas="byte_array_sort">g_byte_array_sort</primary></indexterm>
<programlisting language="C"><link linkend="void"><returnvalue>void</returnvalue></link>
g_byte_array_sort (<parameter><link linkend="GByteArray"><type>GByteArray</type></link> *array</parameter>,
                   <parameter><link linkend="GCompareFunc"><type>GCompareFunc</type></link> compare_func</parameter>);</programlisting>
<para>Sorts a byte array, using <parameter>compare_func</parameter>
 which should be a
<link linkend="qsort"><function>qsort()</function></link>-style comparison function (returns less than zero for first
arg is less than second arg, zero for equal, greater than zero if
first arg is greater than second arg).</para>
<para>If two array elements compare equal, their order in the sorted array
is undefined. If you want equal elements to keep their order (i.e.
you want a stable sort) you can write a comparison function that,
if two elements would otherwise compare equal, compares them by
their addresses.</para>
<refsect3 id="g-byte-array-sort.parameters" role="parameters">
<title>Parameters</title>
<informaltable role="parameters_table" pgwide="1" frame="none">
<tgroup cols="3">
<colspec colname="parameters_name" colwidth="150px"/>
<colspec colname="parameters_description"/>
<colspec colname="parameters_annotations" colwidth="200px"/>
<tbody>
<row><entry role="parameter_name"><para>array</para></entry>
<entry role="parameter_description"><para>a <link linkend="GByteArray"><type>GByteArray</type></link></para></entry>
<entry role="parameter_annotations"></entry></row>
<row><entry role="parameter_name"><para>compare_func</para></entry>
<entry role="parameter_description"><para>comparison function</para></entry>
<entry role="parameter_annotations"></entry></row>
</tbody></tgroup></informaltable>
</refsect3></refsect2>
<refsect2 id="g-byte-array-sort-with-data" role="function">
<title>g_byte_array_sort_with_data&#160;()</title>
<indexterm zone="g-byte-array-sort-with-data"><primary sortas="byte_array_sort_with_data">g_byte_array_sort_with_data</primary></indexterm>
<programlisting language="C"><link linkend="void"><returnvalue>void</returnvalue></link>
g_byte_array_sort_with_data (<parameter><link linkend="GByteArray"><type>GByteArray</type></link> *array</parameter>,
                             <parameter><link linkend="GCompareDataFunc"><type>GCompareDataFunc</type></link> compare_func</parameter>,
                             <parameter><link linkend="gpointer"><type>gpointer</type></link> user_data</parameter>);</programlisting>
<para>Like <link linkend="g-byte-array-sort"><function>g_byte_array_sort()</function></link>, but the comparison function takes an extra
user data argument.</para>
<refsect3 id="g-byte-array-sort-with-data.parameters" role="parameters">
<title>Parameters</title>
<informaltable role="parameters_table" pgwide="1" frame="none">
<tgroup cols="3">
<colspec colname="parameters_name" colwidth="150px"/>
<colspec colname="parameters_description"/>
<colspec colname="parameters_annotations" colwidth="200px"/>
<tbody>
<row><entry role="parameter_name"><para>array</para></entry>
<entry role="parameter_description"><para>a <link linkend="GByteArray"><type>GByteArray</type></link></para></entry>
<entry role="parameter_annotations"></entry></row>
<row><entry role="parameter_name"><para>compare_func</para></entry>
<entry role="parameter_description"><para>comparison function</para></entry>
<entry role="parameter_annotations"></entry></row>
<row><entry role="parameter_name"><para>user_data</para></entry>
<entry role="parameter_description"><para>data to pass to <parameter>compare_func</parameter>
</para></entry>
<entry role="parameter_annotations"></entry></row>
</tbody></tgroup></informaltable>
</refsect3></refsect2>
<refsect2 id="g-byte-array-set-size" role="function">
<title>g_byte_array_set_size&#160;()</title>
<indexterm zone="g-byte-array-set-size"><primary sortas="byte_array_set_size">g_byte_array_set_size</primary></indexterm>
<programlisting language="C"><link linkend="GByteArray"><returnvalue>GByteArray</returnvalue></link>&#160;*
g_byte_array_set_size (<parameter><link linkend="GByteArray"><type>GByteArray</type></link> *array</parameter>,
                       <parameter><link linkend="guint"><type>guint</type></link> length</parameter>);</programlisting>
<para>Sets the size of the <link linkend="GByteArray"><type>GByteArray</type></link>, expanding it if necessary.</para>
<refsect3 id="g-byte-array-set-size.parameters" role="parameters">
<title>Parameters</title>
<informaltable role="parameters_table" pgwide="1" frame="none">
<tgroup cols="3">
<colspec colname="parameters_name" colwidth="150px"/>
<colspec colname="parameters_description"/>
<colspec colname="parameters_annotations" colwidth="200px"/>
<tbody>
<row><entry role="parameter_name"><para>array</para></entry>
<entry role="parameter_description"><para>a <link linkend="GByteArray"><type>GByteArray</type></link></para></entry>
<entry role="parameter_annotations"></entry></row>
<row><entry role="parameter_name"><para>length</para></entry>
<entry role="parameter_description"><para>the new size of the <link linkend="GByteArray"><type>GByteArray</type></link></para></entry>
<entry role="parameter_annotations"></entry></row>
</tbody></tgroup></informaltable>
</refsect3><refsect3 id="g-byte-array-set-size.returns" role="returns">
<title>Returns</title>
<para> the <link linkend="GByteArray"><type>GByteArray</type></link></para>
</refsect3></refsect2>
<refsect2 id="g-byte-array-free" role="function">
<title>g_byte_array_free&#160;()</title>
<indexterm zone="g-byte-array-free"><primary sortas="byte_array_free">g_byte_array_free</primary></indexterm>
<programlisting language="C"><link linkend="guint8"><returnvalue>guint8</returnvalue></link>&#160;*
g_byte_array_free (<parameter><link linkend="GByteArray"><type>GByteArray</type></link> *array</parameter>,
                   <parameter><link linkend="gboolean"><type>gboolean</type></link> free_segment</parameter>);</programlisting>
<para>Frees the memory allocated by the <link linkend="GByteArray"><type>GByteArray</type></link>. If <parameter>free_segment</parameter>
 is
<link linkend="TRUE:CAPS"><literal>TRUE</literal></link> it frees the actual byte data. If the reference count of
<parameter>array</parameter>
 is greater than one, the <link linkend="GByteArray"><type>GByteArray</type></link> wrapper is preserved but
the size of <parameter>array</parameter>
 will be set to zero.</para>
<refsect3 id="g-byte-array-free.parameters" role="parameters">
<title>Parameters</title>
<informaltable role="parameters_table" pgwide="1" frame="none">
<tgroup cols="3">
<colspec colname="parameters_name" colwidth="150px"/>
<colspec colname="parameters_description"/>
<colspec colname="parameters_annotations" colwidth="200px"/>
<tbody>
<row><entry role="parameter_name"><para>array</para></entry>
<entry role="parameter_description"><para>a <link linkend="GByteArray"><type>GByteArray</type></link></para></entry>
<entry role="parameter_annotations"></entry></row>
<row><entry role="parameter_name"><para>free_segment</para></entry>
<entry role="parameter_description"><para>if <link linkend="TRUE:CAPS"><literal>TRUE</literal></link> the actual byte data is freed as well</para></entry>
<entry role="parameter_annotations"></entry></row>
</tbody></tgroup></informaltable>
</refsect3><refsect3 id="g-byte-array-free.returns" role="returns">
<title>Returns</title>
<para> the element data if <parameter>free_segment</parameter>
is <link linkend="FALSE:CAPS"><literal>FALSE</literal></link>, otherwise
<link linkend="NULL:CAPS"><literal>NULL</literal></link>.  The element data should be freed using <link linkend="g-free"><function>g_free()</function></link>.</para>
</refsect3></refsect2>
<refsect2 id="g-byte-array-free-to-bytes" role="function" condition="since:2.32">
<title>g_byte_array_free_to_bytes&#160;()</title>
<indexterm zone="g-byte-array-free-to-bytes" role="2.32"><primary sortas="byte_array_free_to_bytes">g_byte_array_free_to_bytes</primary></indexterm>
<programlisting language="C"><link linkend="GBytes"><returnvalue>GBytes</returnvalue></link>&#160;*
g_byte_array_free_to_bytes (<parameter><link linkend="GByteArray"><type>GByteArray</type></link> *array</parameter>);</programlisting>
<para>Transfers the data from the <link linkend="GByteArray"><type>GByteArray</type></link> into a new immutable <link linkend="GBytes"><type>GBytes</type></link>.</para>
<para>The <link linkend="GByteArray"><type>GByteArray</type></link> is freed unless the reference count of <parameter>array</parameter>
 is greater
than one, the <link linkend="GByteArray"><type>GByteArray</type></link> wrapper is preserved but the size of <parameter>array</parameter>

will be set to zero.</para>
<para>This is identical to using <link linkend="g-bytes-new-take"><function>g_bytes_new_take()</function></link> and <link linkend="g-byte-array-free"><function>g_byte_array_free()</function></link>
together.</para>
<refsect3 id="g-byte-array-free-to-bytes.parameters" role="parameters">
<title>Parameters</title>
<informaltable role="parameters_table" pgwide="1" frame="none">
<tgroup cols="3">
<colspec colname="parameters_name" colwidth="150px"/>
<colspec colname="parameters_description"/>
<colspec colname="parameters_annotations" colwidth="200px"/>
<tbody>
<row><entry role="parameter_name"><para>array</para></entry>
<entry role="parameter_description"><para>a <link linkend="GByteArray"><type>GByteArray</type></link>. </para></entry>
<entry role="parameter_annotations"><emphasis role="annotation">[<acronym>transfer full</acronym>]</emphasis></entry></row>
</tbody></tgroup></informaltable>
</refsect3><refsect3 id="g-byte-array-free-to-bytes.returns" role="returns">
<title>Returns</title>
<para>a new immutable <link linkend="GBytes"><type>GBytes</type></link> representing same
byte data that was in the array. </para>
<para><emphasis role="annotation">[<acronym>transfer full</acronym>]</emphasis></para>
</refsect3><para role="since">Since: <link linkend="api-index-2.32">2.32</link></para></refsect2>
<refsect2 id="g-bytes-new" role="function" condition="since:2.32">
<title>g_bytes_new&#160;()</title>
<indexterm zone="g-bytes-new" role="2.32"><primary sortas="bytes_new">g_bytes_new</primary></indexterm>
<programlisting language="C"><link linkend="GBytes"><returnvalue>GBytes</returnvalue></link>&#160;*
g_bytes_new (<parameter><link linkend="gconstpointer"><type>gconstpointer</type></link> data</parameter>,
             <parameter><link linkend="gsize"><type>gsize</type></link> size</parameter>);</programlisting>
<para>Creates a new <link linkend="GBytes"><type>GBytes</type></link> from <parameter>data</parameter>
.</para>
<para><parameter>data</parameter>
 is copied. If <parameter>size</parameter>
 is 0, <parameter>data</parameter>
 may be <link linkend="NULL:CAPS"><literal>NULL</literal></link>.</para>
<refsect3 id="g-bytes-new.parameters" role="parameters">
<title>Parameters</title>
<informaltable role="parameters_table" pgwide="1" frame="none">
<tgroup cols="3">
<colspec colname="parameters_name" colwidth="150px"/>
<colspec colname="parameters_description"/>
<colspec colname="parameters_annotations" colwidth="200px"/>
<tbody>
<row><entry role="parameter_name"><para>data</para></entry>
<entry role="parameter_description"><para>the data to be used for the bytes. </para></entry>
<entry role="parameter_annotations"><emphasis role="annotation">[<acronym>transfer none</acronym>][<acronym>array</acronym> length=size][<acronym>element-type</acronym> guint8][<acronym>nullable</acronym>]</emphasis></entry></row>
<row><entry role="parameter_name"><para>size</para></entry>
<entry role="parameter_description"><para>the size of <parameter>data</parameter>
</para></entry>
<entry role="parameter_annotations"></entry></row>
</tbody></tgroup></informaltable>
</refsect3><refsect3 id="g-bytes-new.returns" role="returns">
<title>Returns</title>
<para>a new <link linkend="GBytes"><type>GBytes</type></link>. </para>
<para><emphasis role="annotation">[<acronym>transfer full</acronym>]</emphasis></para>
</refsect3><para role="since">Since: <link linkend="api-index-2.32">2.32</link></para></refsect2>
<refsect2 id="g-bytes-new-take" role="function" condition="since:2.32">
<title>g_bytes_new_take&#160;()</title>
<indexterm zone="g-bytes-new-take" role="2.32"><primary sortas="bytes_new_take">g_bytes_new_take</primary></indexterm>
<programlisting language="C"><link linkend="GBytes"><returnvalue>GBytes</returnvalue></link>&#160;*
g_bytes_new_take (<parameter><link linkend="gpointer"><type>gpointer</type></link> data</parameter>,
                  <parameter><link linkend="gsize"><type>gsize</type></link> size</parameter>);</programlisting>
<para>Creates a new <link linkend="GBytes"><type>GBytes</type></link> from <parameter>data</parameter>
.</para>
<para>After this call, <parameter>data</parameter>
 belongs to the bytes and may no longer be
modified by the caller.  <link linkend="g-free"><function>g_free()</function></link> will be called on <parameter>data</parameter>
 when the
bytes is no longer in use. Because of this <parameter>data</parameter>
 must have been created by
a call to <link linkend="g-malloc"><function>g_malloc()</function></link>, <link linkend="g-malloc0"><function>g_malloc0()</function></link> or <link linkend="g-realloc"><function>g_realloc()</function></link> or by one of the many
functions that wrap these calls (such as <link linkend="g-new"><function>g_new()</function></link>, <link linkend="g-strdup"><function>g_strdup()</function></link>, etc).</para>
<para>For creating <link linkend="GBytes"><type>GBytes</type></link> with memory from other allocators, see
<link linkend="g-bytes-new-with-free-func"><function>g_bytes_new_with_free_func()</function></link>.</para>
<para><parameter>data</parameter>
 may be <link linkend="NULL:CAPS"><literal>NULL</literal></link> if <parameter>size</parameter>
 is 0.</para>
<refsect3 id="g-bytes-new-take.parameters" role="parameters">
<title>Parameters</title>
<informaltable role="parameters_table" pgwide="1" frame="none">
<tgroup cols="3">
<colspec colname="parameters_name" colwidth="150px"/>
<colspec colname="parameters_description"/>
<colspec colname="parameters_annotations" colwidth="200px"/>
<tbody>
<row><entry role="parameter_name"><para>data</para></entry>
<entry role="parameter_description"><para>the data to be used for the bytes. </para></entry>
<entry role="parameter_annotations"><emphasis role="annotation">[<acronym>transfer full</acronym>][<acronym>array</acronym> length=size][<acronym>element-type</acronym> guint8][<acronym>nullable</acronym>]</emphasis></entry></row>
<row><entry role="parameter_name"><para>size</para></entry>
<entry role="parameter_description"><para>the size of <parameter>data</parameter>
</para></entry>
<entry role="parameter_annotations"></entry></row>
</tbody></tgroup></informaltable>
</refsect3><refsect3 id="g-bytes-new-take.returns" role="returns">
<title>Returns</title>
<para>a new <link linkend="GBytes"><type>GBytes</type></link>. </para>
<para><emphasis role="annotation">[<acronym>transfer full</acronym>]</emphasis></para>
</refsect3><para role="since">Since: <link linkend="api-index-2.32">2.32</link></para></refsect2>
<refsect2 id="g-bytes-new-static" role="function" condition="since:2.32">
<title>g_bytes_new_static&#160;()</title>
<indexterm zone="g-bytes-new-static" role="2.32"><primary sortas="bytes_new_static">g_bytes_new_static</primary></indexterm>
<programlisting language="C"><link linkend="GBytes"><returnvalue>GBytes</returnvalue></link>&#160;*
g_bytes_new_static (<parameter><link linkend="gconstpointer"><type>gconstpointer</type></link> data</parameter>,
                    <parameter><link linkend="gsize"><type>gsize</type></link> size</parameter>);</programlisting>
<para>Creates a new <link linkend="GBytes"><type>GBytes</type></link> from static data.</para>
<para><parameter>data</parameter>
 must be static (ie: never modified or freed). It may be <link linkend="NULL:CAPS"><literal>NULL</literal></link> if <parameter>size</parameter>

is 0.</para>

<para><emphasis role="annotation">[<acronym>skip</acronym>]</emphasis></para><refsect3 id="g-bytes-new-static.parameters" role="parameters">
<title>Parameters</title>
<informaltable role="parameters_table" pgwide="1" frame="none">
<tgroup cols="3">
<colspec colname="parameters_name" colwidth="150px"/>
<colspec colname="parameters_description"/>
<colspec colname="parameters_annotations" colwidth="200px"/>
<tbody>
<row><entry role="parameter_name"><para>data</para></entry>
<entry role="parameter_description"><para>the data to be used for the bytes. </para></entry>
<entry role="parameter_annotations"><emphasis role="annotation">[<acronym>transfer full</acronym>][<acronym>array</acronym> length=size][<acronym>element-type</acronym> guint8][<acronym>nullable</acronym>]</emphasis></entry></row>
<row><entry role="parameter_name"><para>size</para></entry>
<entry role="parameter_description"><para>the size of <parameter>data</parameter>
</para></entry>
<entry role="parameter_annotations"></entry></row>
</tbody></tgroup></informaltable>
</refsect3><refsect3 id="g-bytes-new-static.returns" role="returns">
<title>Returns</title>
<para>a new <link linkend="GBytes"><type>GBytes</type></link>. </para>
<para><emphasis role="annotation">[<acronym>transfer full</acronym>]</emphasis></para>
</refsect3><para role="since">Since: <link linkend="api-index-2.32">2.32</link></para></refsect2>
<refsect2 id="g-bytes-new-with-free-func" role="function" condition="since:2.32">
<title>g_bytes_new_with_free_func&#160;()</title>
<indexterm zone="g-bytes-new-with-free-func" role="2.32"><primary sortas="bytes_new_with_free_func">g_bytes_new_with_free_func</primary></indexterm>
<programlisting language="C"><link linkend="GBytes"><returnvalue>GBytes</returnvalue></link>&#160;*
g_bytes_new_with_free_func (<parameter><link linkend="gconstpointer"><type>gconstpointer</type></link> data</parameter>,
                            <parameter><link linkend="gsize"><type>gsize</type></link> size</parameter>,
                            <parameter><link linkend="GDestroyNotify"><type>GDestroyNotify</type></link> free_func</parameter>,
                            <parameter><link linkend="gpointer"><type>gpointer</type></link> user_data</parameter>);</programlisting>
<para>Creates a <link linkend="GBytes"><type>GBytes</type></link> from <parameter>data</parameter>
.</para>
<para>When the last reference is dropped, <parameter>free_func</parameter>
 will be called with the
<parameter>user_data</parameter>
 argument.</para>
<para><parameter>data</parameter>
 must not be modified after this call is made until <parameter>free_func</parameter>
 has
been called to indicate that the bytes is no longer in use.</para>
<para><parameter>data</parameter>
 may be <link linkend="NULL:CAPS"><literal>NULL</literal></link> if <parameter>size</parameter>
 is 0.</para>

<para><emphasis role="annotation">[<acronym>skip</acronym>]</emphasis></para><refsect3 id="g-bytes-new-with-free-func.parameters" role="parameters">
<title>Parameters</title>
<informaltable role="parameters_table" pgwide="1" frame="none">
<tgroup cols="3">
<colspec colname="parameters_name" colwidth="150px"/>
<colspec colname="parameters_description"/>
<colspec colname="parameters_annotations" colwidth="200px"/>
<tbody>
<row><entry role="parameter_name"><para>data</para></entry>
<entry role="parameter_description"><para>the data to be used for the bytes. </para></entry>
<entry role="parameter_annotations"><emphasis role="annotation">[<acronym>array</acronym> length=size][<acronym>element-type</acronym> guint8][<acronym>nullable</acronym>]</emphasis></entry></row>
<row><entry role="parameter_name"><para>size</para></entry>
<entry role="parameter_description"><para>the size of <parameter>data</parameter>
</para></entry>
<entry role="parameter_annotations"></entry></row>
<row><entry role="parameter_name"><para>free_func</para></entry>
<entry role="parameter_description"><para>the function to call to release the data</para></entry>
<entry role="parameter_annotations"></entry></row>
<row><entry role="parameter_name"><para>user_data</para></entry>
<entry role="parameter_description"><para>data to pass to <parameter>free_func</parameter>
</para></entry>
<entry role="parameter_annotations"></entry></row>
</tbody></tgroup></informaltable>
</refsect3><refsect3 id="g-bytes-new-with-free-func.returns" role="returns">
<title>Returns</title>
<para>a new <link linkend="GBytes"><type>GBytes</type></link>. </para>
<para><emphasis role="annotation">[<acronym>transfer full</acronym>]</emphasis></para>
</refsect3><para role="since">Since: <link linkend="api-index-2.32">2.32</link></para></refsect2>
<refsect2 id="g-bytes-new-from-bytes" role="function" condition="since:2.32">
<title>g_bytes_new_from_bytes&#160;()</title>
<indexterm zone="g-bytes-new-from-bytes" role="2.32"><primary sortas="bytes_new_from_bytes">g_bytes_new_from_bytes</primary></indexterm>
<programlisting language="C"><link linkend="GBytes"><returnvalue>GBytes</returnvalue></link>&#160;*
g_bytes_new_from_bytes (<parameter><link linkend="GBytes"><type>GBytes</type></link> *bytes</parameter>,
                        <parameter><link linkend="gsize"><type>gsize</type></link> offset</parameter>,
                        <parameter><link linkend="gsize"><type>gsize</type></link> length</parameter>);</programlisting>
<para>Creates a <link linkend="GBytes"><type>GBytes</type></link> which is a subsection of another <link linkend="GBytes"><type>GBytes</type></link>. The <parameter>offset</parameter>
 +
<parameter>length</parameter>
 may not be longer than the size of <parameter>bytes</parameter>
.</para>
<para>A reference to <parameter>bytes</parameter>
 will be held by the newly created <link linkend="GBytes"><type>GBytes</type></link> until
the byte data is no longer needed.</para>
<para>Since 2.56, if <parameter>offset</parameter>
 is 0 and <parameter>length</parameter>
 matches the size of <parameter>bytes</parameter>
, then
<parameter>bytes</parameter>
 will be returned with the reference count incremented by 1. If <parameter>bytes</parameter>

is a slice of another <link linkend="GBytes"><type>GBytes</type></link>, then the resulting <link linkend="GBytes"><type>GBytes</type></link> will reference
the same <link linkend="GBytes"><type>GBytes</type></link> instead of <parameter>bytes</parameter>
. This allows consumers to simplify the
usage of <link linkend="GBytes"><type>GBytes</type></link> when asynchronously writing to streams.</para>
<refsect3 id="g-bytes-new-from-bytes.parameters" role="parameters">
<title>Parameters</title>
<informaltable role="parameters_table" pgwide="1" frame="none">
<tgroup cols="3">
<colspec colname="parameters_name" colwidth="150px"/>
<colspec colname="parameters_description"/>
<colspec colname="parameters_annotations" colwidth="200px"/>
<tbody>
<row><entry role="parameter_name"><para>bytes</para></entry>
<entry role="parameter_description"><para>a <link linkend="GBytes"><type>GBytes</type></link></para></entry>
<entry role="parameter_annotations"></entry></row>
<row><entry role="parameter_name"><para>offset</para></entry>
<entry role="parameter_description"><para>offset which subsection starts at</para></entry>
<entry role="parameter_annotations"></entry></row>
<row><entry role="parameter_name"><para>length</para></entry>
<entry role="parameter_description"><para>length of subsection</para></entry>
<entry role="parameter_annotations"></entry></row>
</tbody></tgroup></informaltable>
</refsect3><refsect3 id="g-bytes-new-from-bytes.returns" role="returns">
<title>Returns</title>
<para>a new <link linkend="GBytes"><type>GBytes</type></link>. </para>
<para><emphasis role="annotation">[<acronym>transfer full</acronym>]</emphasis></para>
</refsect3><para role="since">Since: <link linkend="api-index-2.32">2.32</link></para></refsect2>
<refsect2 id="g-bytes-get-data" role="function" condition="since:2.32">
<title>g_bytes_get_data&#160;()</title>
<indexterm zone="g-bytes-get-data" role="2.32"><primary sortas="bytes_get_data">g_bytes_get_data</primary></indexterm>
<programlisting language="C"><link linkend="gconstpointer"><returnvalue>gconstpointer</returnvalue></link>
g_bytes_get_data (<parameter><link linkend="GBytes"><type>GBytes</type></link> *bytes</parameter>,
                  <parameter><link linkend="gsize"><type>gsize</type></link> *size</parameter>);</programlisting>
<para>Get the byte data in the <link linkend="GBytes"><type>GBytes</type></link>. This data should not be modified.</para>
<para>This function will always return the same pointer for a given <link linkend="GBytes"><type>GBytes</type></link>.</para>
<para><link linkend="NULL:CAPS"><literal>NULL</literal></link> may be returned if <parameter>size</parameter>
 is 0. This is not guaranteed, as the <link linkend="GBytes"><type>GBytes</type></link>
may represent an empty string with <parameter>data</parameter>
 non-<link linkend="NULL:CAPS"><literal>NULL</literal></link> and <parameter>size</parameter>
 as 0. <link linkend="NULL:CAPS"><literal>NULL</literal></link> will
not be returned if <parameter>size</parameter>
 is non-zero.</para>
<refsect3 id="g-bytes-get-data.parameters" role="parameters">
<title>Parameters</title>
<informaltable role="parameters_table" pgwide="1" frame="none">
<tgroup cols="3">
<colspec colname="parameters_name" colwidth="150px"/>
<colspec colname="parameters_description"/>
<colspec colname="parameters_annotations" colwidth="200px"/>
<tbody>
<row><entry role="parameter_name"><para>bytes</para></entry>
<entry role="parameter_description"><para>a <link linkend="GBytes"><type>GBytes</type></link></para></entry>
<entry role="parameter_annotations"></entry></row>
<row><entry role="parameter_name"><para>size</para></entry>
<entry role="parameter_description"><para>location to return size of byte data. </para></entry>
<entry role="parameter_annotations"><emphasis role="annotation">[<acronym>out</acronym>][<acronym>optional</acronym>]</emphasis></entry></row>
</tbody></tgroup></informaltable>
</refsect3><refsect3 id="g-bytes-get-data.returns" role="returns">
<title>Returns</title>
<para>a pointer to the byte data, or <link linkend="NULL:CAPS"><literal>NULL</literal></link>. </para>
<para><emphasis role="annotation">[<acronym>transfer none</acronym>][<acronym>array</acronym> length=size][<acronym>element-type</acronym> guint8][<acronym>nullable</acronym>]</emphasis></para>
</refsect3><para role="since">Since: <link linkend="api-index-2.32">2.32</link></para></refsect2>
<refsect2 id="g-bytes-get-size" role="function" condition="since:2.32">
<title>g_bytes_get_size&#160;()</title>
<indexterm zone="g-bytes-get-size" role="2.32"><primary sortas="bytes_get_size">g_bytes_get_size</primary></indexterm>
<programlisting language="C"><link linkend="gsize"><returnvalue>gsize</returnvalue></link>
g_bytes_get_size (<parameter><link linkend="GBytes"><type>GBytes</type></link> *bytes</parameter>);</programlisting>
<para>Get the size of the byte data in the <link linkend="GBytes"><type>GBytes</type></link>.</para>
<para>This function will always return the same value for a given <link linkend="GBytes"><type>GBytes</type></link>.</para>
<refsect3 id="g-bytes-get-size.parameters" role="parameters">
<title>Parameters</title>
<informaltable role="parameters_table" pgwide="1" frame="none">
<tgroup cols="3">
<colspec colname="parameters_name" colwidth="150px"/>
<colspec colname="parameters_description"/>
<colspec colname="parameters_annotations" colwidth="200px"/>
<tbody>
<row><entry role="parameter_name"><para>bytes</para></entry>
<entry role="parameter_description"><para>a <link linkend="GBytes"><type>GBytes</type></link></para></entry>
<entry role="parameter_annotations"></entry></row>
</tbody></tgroup></informaltable>
</refsect3><refsect3 id="g-bytes-get-size.returns" role="returns">
<title>Returns</title>
<para> the size</para>
</refsect3><para role="since">Since: <link linkend="api-index-2.32">2.32</link></para></refsect2>
<refsect2 id="g-bytes-hash" role="function" condition="since:2.32">
<title>g_bytes_hash&#160;()</title>
<indexterm zone="g-bytes-hash" role="2.32"><primary sortas="bytes_hash">g_bytes_hash</primary></indexterm>
<programlisting language="C"><link linkend="guint"><returnvalue>guint</returnvalue></link>
g_bytes_hash (<parameter><link linkend="gconstpointer"><type>gconstpointer</type></link> bytes</parameter>);</programlisting>
<para>Creates an integer hash code for the byte data in the <link linkend="GBytes"><type>GBytes</type></link>.</para>
<para>This function can be passed to <link linkend="g-hash-table-new"><function>g_hash_table_new()</function></link> as the <parameter>key_hash_func</parameter>

parameter, when using non-<link linkend="NULL:CAPS"><literal>NULL</literal></link> <link linkend="GBytes"><type>GBytes</type></link> pointers as keys in a <link linkend="GHashTable"><type>GHashTable</type></link>.</para>
<refsect3 id="g-bytes-hash.parameters" role="parameters">
<title>Parameters</title>
<informaltable role="parameters_table" pgwide="1" frame="none">
<tgroup cols="3">
<colspec colname="parameters_name" colwidth="150px"/>
<colspec colname="parameters_description"/>
<colspec colname="parameters_annotations" colwidth="200px"/>
<tbody>
<row><entry role="parameter_name"><para>bytes</para></entry>
<entry role="parameter_description"><para>a pointer to a <link linkend="GBytes"><type>GBytes</type></link> key. </para></entry>
<entry role="parameter_annotations"><emphasis role="annotation">[<acronym>type</acronym> GLib.Bytes]</emphasis></entry></row>
</tbody></tgroup></informaltable>
</refsect3><refsect3 id="g-bytes-hash.returns" role="returns">
<title>Returns</title>
<para> a hash value corresponding to the key.</para>
</refsect3><para role="since">Since: <link linkend="api-index-2.32">2.32</link></para></refsect2>
<refsect2 id="g-bytes-equal" role="function" condition="since:2.32">
<title>g_bytes_equal&#160;()</title>
<indexterm zone="g-bytes-equal" role="2.32"><primary sortas="bytes_equal">g_bytes_equal</primary></indexterm>
<programlisting language="C"><link linkend="gboolean"><returnvalue>gboolean</returnvalue></link>
g_bytes_equal (<parameter><link linkend="gconstpointer"><type>gconstpointer</type></link> bytes1</parameter>,
               <parameter><link linkend="gconstpointer"><type>gconstpointer</type></link> bytes2</parameter>);</programlisting>
<para>Compares the two <link linkend="GBytes"><type>GBytes</type></link> values being pointed to and returns
<link linkend="TRUE:CAPS"><literal>TRUE</literal></link> if they are equal.</para>
<para>This function can be passed to <link linkend="g-hash-table-new"><function>g_hash_table_new()</function></link> as the <parameter>key_equal_func</parameter>

parameter, when using non-<link linkend="NULL:CAPS"><literal>NULL</literal></link> <link linkend="GBytes"><type>GBytes</type></link> pointers as keys in a <link linkend="GHashTable"><type>GHashTable</type></link>.</para>
<refsect3 id="g-bytes-equal.parameters" role="parameters">
<title>Parameters</title>
<informaltable role="parameters_table" pgwide="1" frame="none">
<tgroup cols="3">
<colspec colname="parameters_name" colwidth="150px"/>
<colspec colname="parameters_description"/>
<colspec colname="parameters_annotations" colwidth="200px"/>
<tbody>
<row><entry role="parameter_name"><para>bytes1</para></entry>
<entry role="parameter_description"><para>a pointer to a <link linkend="GBytes"><type>GBytes</type></link>. </para></entry>
<entry role="parameter_annotations"><emphasis role="annotation">[<acronym>type</acronym> GLib.Bytes]</emphasis></entry></row>
<row><entry role="parameter_name"><para>bytes2</para></entry>
<entry role="parameter_description"><para>a pointer to a <link linkend="GBytes"><type>GBytes</type></link> to compare with <parameter>bytes1</parameter>
. </para></entry>
<entry role="parameter_annotations"><emphasis role="annotation">[<acronym>type</acronym> GLib.Bytes]</emphasis></entry></row>
</tbody></tgroup></informaltable>
</refsect3><refsect3 id="g-bytes-equal.returns" role="returns">
<title>Returns</title>
<para> <link linkend="TRUE:CAPS"><literal>TRUE</literal></link> if the two keys match.</para>
</refsect3><para role="since">Since: <link linkend="api-index-2.32">2.32</link></para></refsect2>
<refsect2 id="g-bytes-compare" role="function" condition="since:2.32">
<title>g_bytes_compare&#160;()</title>
<indexterm zone="g-bytes-compare" role="2.32"><primary sortas="bytes_compare">g_bytes_compare</primary></indexterm>
<programlisting language="C"><link linkend="gint"><returnvalue>gint</returnvalue></link>
g_bytes_compare (<parameter><link linkend="gconstpointer"><type>gconstpointer</type></link> bytes1</parameter>,
                 <parameter><link linkend="gconstpointer"><type>gconstpointer</type></link> bytes2</parameter>);</programlisting>
<para>Compares the two <link linkend="GBytes"><type>GBytes</type></link> values.</para>
<para>This function can be used to sort GBytes instances in lexicographical order.</para>
<para>If <parameter>bytes1</parameter>
 and <parameter>bytes2</parameter>
 have different length but the shorter one is a
prefix of the longer one then the shorter one is considered to be less than
the longer one. Otherwise the first byte where both differ is used for
comparison. If <parameter>bytes1</parameter>
 has a smaller value at that position it is
considered less, otherwise greater than <parameter>bytes2</parameter>
.</para>
<refsect3 id="g-bytes-compare.parameters" role="parameters">
<title>Parameters</title>
<informaltable role="parameters_table" pgwide="1" frame="none">
<tgroup cols="3">
<colspec colname="parameters_name" colwidth="150px"/>
<colspec colname="parameters_description"/>
<colspec colname="parameters_annotations" colwidth="200px"/>
<tbody>
<row><entry role="parameter_name"><para>bytes1</para></entry>
<entry role="parameter_description"><para>a pointer to a <link linkend="GBytes"><type>GBytes</type></link>. </para></entry>
<entry role="parameter_annotations"><emphasis role="annotation">[<acronym>type</acronym> GLib.Bytes]</emphasis></entry></row>
<row><entry role="parameter_name"><para>bytes2</para></entry>
<entry role="parameter_description"><para>a pointer to a <link linkend="GBytes"><type>GBytes</type></link> to compare with <parameter>bytes1</parameter>
. </para></entry>
<entry role="parameter_annotations"><emphasis role="annotation">[<acronym>type</acronym> GLib.Bytes]</emphasis></entry></row>
</tbody></tgroup></informaltable>
</refsect3><refsect3 id="g-bytes-compare.returns" role="returns">
<title>Returns</title>
<para> a negative value if <parameter>bytes1</parameter>
is less than <parameter>bytes2</parameter>
, a positive value
if <parameter>bytes1</parameter>
is greater than <parameter>bytes2</parameter>
, and zero if <parameter>bytes1</parameter>
is equal to
<parameter>bytes2</parameter>
</para>
</refsect3><para role="since">Since: <link linkend="api-index-2.32">2.32</link></para></refsect2>
<refsect2 id="g-bytes-ref" role="function" condition="since:2.32">
<title>g_bytes_ref&#160;()</title>
<indexterm zone="g-bytes-ref" role="2.32"><primary sortas="bytes_ref">g_bytes_ref</primary></indexterm>
<programlisting language="C"><link linkend="GBytes"><returnvalue>GBytes</returnvalue></link>&#160;*
g_bytes_ref (<parameter><link linkend="GBytes"><type>GBytes</type></link> *bytes</parameter>);</programlisting>
<para>Increase the reference count on <parameter>bytes</parameter>
.</para>
<refsect3 id="g-bytes-ref.parameters" role="parameters">
<title>Parameters</title>
<informaltable role="parameters_table" pgwide="1" frame="none">
<tgroup cols="3">
<colspec colname="parameters_name" colwidth="150px"/>
<colspec colname="parameters_description"/>
<colspec colname="parameters_annotations" colwidth="200px"/>
<tbody>
<row><entry role="parameter_name"><para>bytes</para></entry>
<entry role="parameter_description"><para>a <link linkend="GBytes"><type>GBytes</type></link></para></entry>
<entry role="parameter_annotations"></entry></row>
</tbody></tgroup></informaltable>
</refsect3><refsect3 id="g-bytes-ref.returns" role="returns">
<title>Returns</title>
<para> the <link linkend="GBytes"><type>GBytes</type></link></para>
</refsect3><para role="since">Since: <link linkend="api-index-2.32">2.32</link></para></refsect2>
<refsect2 id="g-bytes-unref" role="function" condition="since:2.32">
<title>g_bytes_unref&#160;()</title>
<indexterm zone="g-bytes-unref" role="2.32"><primary sortas="bytes_unref">g_bytes_unref</primary></indexterm>
<programlisting language="C"><link linkend="void"><returnvalue>void</returnvalue></link>
g_bytes_unref (<parameter><link linkend="GBytes"><type>GBytes</type></link> *bytes</parameter>);</programlisting>
<para>Releases a reference on <parameter>bytes</parameter>
.  This may result in the bytes being
freed. If <parameter>bytes</parameter>
 is <link linkend="NULL:CAPS"><literal>NULL</literal></link>, it will return immediately.</para>
<refsect3 id="g-bytes-unref.parameters" role="parameters">
<title>Parameters</title>
<informaltable role="parameters_table" pgwide="1" frame="none">
<tgroup cols="3">
<colspec colname="parameters_name" colwidth="150px"/>
<colspec colname="parameters_description"/>
<colspec colname="parameters_annotations" colwidth="200px"/>
<tbody>
<row><entry role="parameter_name"><para>bytes</para></entry>
<entry role="parameter_description"><para>a <link linkend="GBytes"><type>GBytes</type></link>. </para></entry>
<entry role="parameter_annotations"><emphasis role="annotation">[<acronym>nullable</acronym>]</emphasis></entry></row>
</tbody></tgroup></informaltable>
</refsect3><para role="since">Since: <link linkend="api-index-2.32">2.32</link></para></refsect2>
<refsect2 id="g-bytes-unref-to-data" role="function" condition="since:2.32">
<title>g_bytes_unref_to_data&#160;()</title>
<indexterm zone="g-bytes-unref-to-data" role="2.32"><primary sortas="bytes_unref_to_data">g_bytes_unref_to_data</primary></indexterm>
<programlisting language="C"><link linkend="gpointer"><returnvalue>gpointer</returnvalue></link>
g_bytes_unref_to_data (<parameter><link linkend="GBytes"><type>GBytes</type></link> *bytes</parameter>,
                       <parameter><link linkend="gsize"><type>gsize</type></link> *size</parameter>);</programlisting>
<para>Unreferences the bytes, and returns a pointer the same byte data
contents.</para>
<para>As an optimization, the byte data is returned without copying if this was
the last reference to bytes and bytes was created with <link linkend="g-bytes-new"><function>g_bytes_new()</function></link>,
<link linkend="g-bytes-new-take"><function>g_bytes_new_take()</function></link> or <link linkend="g-byte-array-free-to-bytes"><function>g_byte_array_free_to_bytes()</function></link>. In all other cases the
data is copied.</para>
<refsect3 id="g-bytes-unref-to-data.parameters" role="parameters">
<title>Parameters</title>
<informaltable role="parameters_table" pgwide="1" frame="none">
<tgroup cols="3">
<colspec colname="parameters_name" colwidth="150px"/>
<colspec colname="parameters_description"/>
<colspec colname="parameters_annotations" colwidth="200px"/>
<tbody>
<row><entry role="parameter_name"><para>bytes</para></entry>
<entry role="parameter_description"><para>a <link linkend="GBytes"><type>GBytes</type></link>. </para></entry>
<entry role="parameter_annotations"><emphasis role="annotation">[<acronym>transfer full</acronym>]</emphasis></entry></row>
<row><entry role="parameter_name"><para>size</para></entry>
<entry role="parameter_description"><para>location to place the length of the returned data. </para></entry>
<entry role="parameter_annotations"><emphasis role="annotation">[<acronym>out</acronym>]</emphasis></entry></row>
</tbody></tgroup></informaltable>
</refsect3><refsect3 id="g-bytes-unref-to-data.returns" role="returns">
<title>Returns</title>
<para> (transfer full) (array length=size) (element-type guint8)
(not nullable): a pointer to the same byte data, which should be
freed with <link linkend="g-free"><function>g_free()</function></link></para>
</refsect3><para role="since">Since: <link linkend="api-index-2.32">2.32</link></para></refsect2>
<refsect2 id="g-bytes-unref-to-array" role="function" condition="since:2.32">
<title>g_bytes_unref_to_array&#160;()</title>
<indexterm zone="g-bytes-unref-to-array" role="2.32"><primary sortas="bytes_unref_to_array">g_bytes_unref_to_array</primary></indexterm>
<programlisting language="C"><link linkend="GByteArray"><returnvalue>GByteArray</returnvalue></link>&#160;*
g_bytes_unref_to_array (<parameter><link linkend="GBytes"><type>GBytes</type></link> *bytes</parameter>);</programlisting>
<para>Unreferences the bytes, and returns a new mutable <link linkend="GByteArray"><type>GByteArray</type></link> containing
the same byte data.</para>
<para>As an optimization, the byte data is transferred to the array without copying
if this was the last reference to bytes and bytes was created with
<link linkend="g-bytes-new"><function>g_bytes_new()</function></link>, <link linkend="g-bytes-new-take"><function>g_bytes_new_take()</function></link> or <link linkend="g-byte-array-free-to-bytes"><function>g_byte_array_free_to_bytes()</function></link>. In all
other cases the data is copied.</para>
<refsect3 id="g-bytes-unref-to-array.parameters" role="parameters">
<title>Parameters</title>
<informaltable role="parameters_table" pgwide="1" frame="none">
<tgroup cols="3">
<colspec colname="parameters_name" colwidth="150px"/>
<colspec colname="parameters_description"/>
<colspec colname="parameters_annotations" colwidth="200px"/>
<tbody>
<row><entry role="parameter_name"><para>bytes</para></entry>
<entry role="parameter_description"><para>a <link linkend="GBytes"><type>GBytes</type></link>. </para></entry>
<entry role="parameter_annotations"><emphasis role="annotation">[<acronym>transfer full</acronym>]</emphasis></entry></row>
</tbody></tgroup></informaltable>
</refsect3><refsect3 id="g-bytes-unref-to-array.returns" role="returns">
<title>Returns</title>
<para>a new mutable <link linkend="GByteArray"><type>GByteArray</type></link> containing the same byte data. </para>
<para><emphasis role="annotation">[<acronym>transfer full</acronym>]</emphasis></para>
</refsect3><para role="since">Since: <link linkend="api-index-2.32">2.32</link></para></refsect2>

</refsect1>
<refsect1 id="glib-Byte-Arrays.other_details" role="details">
<title role="details.title">Types and Values</title>
<refsect2 id="GByteArray" role="struct">
<title>struct GByteArray</title>
<indexterm zone="GByteArray"><primary sortas="ByteArray">GByteArray</primary></indexterm>
<programlisting language="C">struct GByteArray {
  guint8 *data;
  guint	  len;
};
</programlisting>
<para>Contains the public fields of a GByteArray.</para>
<refsect3 id="GByteArray.members" role="struct_members">
<title>Members</title>
<informaltable role="struct_members_table" pgwide="1" frame="none">
<tgroup cols="3">
<colspec colname="struct_members_name" colwidth="300px"/>
<colspec colname="struct_members_description"/>
<colspec colname="struct_members_annotations" colwidth="200px"/>
<tbody>
<row role="member"><entry role="struct_member_name"><para><link linkend="guint8"><type>guint8</type></link>&#160;*<structfield id="GByteArray.data">data</structfield>;</para></entry>
<entry role="struct_member_description"><para>a pointer to the element data. The data may be moved as
elements are added to the <link linkend="GByteArray"><type>GByteArray</type></link></para></entry>
<entry role="struct_member_annotations"></entry>
</row>
<row role="member"><entry role="struct_member_name"><para><link linkend="guint"><type>guint</type></link>&#160;<structfield id="GByteArray.len">len</structfield>;</para></entry>
<entry role="struct_member_description"><para>the number of elements in the <link linkend="GByteArray"><type>GByteArray</type></link></para></entry>
<entry role="struct_member_annotations"></entry>
</row>
</tbody></tgroup></informaltable>
</refsect3>
</refsect2>
<refsect2 id="GBytes" role="struct" condition="since:2.32">
<title>GBytes</title>
<indexterm zone="GBytes" role="2.32"><primary sortas="Bytes">GBytes</primary></indexterm>
<programlisting language="C">typedef struct _GBytes GBytes;</programlisting>
<para>A simple refcounted data type representing an immutable sequence of zero or
more bytes from an unspecified origin.</para>
<para>The purpose of a <link linkend="GBytes"><type>GBytes</type></link> is to keep the memory region that it holds
alive for as long as anyone holds a reference to the bytes.  When
the last reference count is dropped, the memory is released. Multiple
unrelated callers can use byte data in the <link linkend="GBytes"><type>GBytes</type></link> without coordinating
their activities, resting assured that the byte data will not change or
move while they hold a reference.</para>
<para>A <link linkend="GBytes"><type>GBytes</type></link> can come from many different origins that may have
different procedures for freeing the memory region.  Examples are
memory from <link linkend="g-malloc"><function>g_malloc()</function></link>, from memory slices, from a <link linkend="GMappedFile"><type>GMappedFile</type></link> or
memory from other allocators.</para>
<para><link linkend="GBytes"><type>GBytes</type></link> work well as keys in <link linkend="GHashTable"><type>GHashTable</type></link>. Use <link linkend="g-bytes-equal"><function>g_bytes_equal()</function></link> and
<link linkend="g-bytes-hash"><function>g_bytes_hash()</function></link> as parameters to <link linkend="g-hash-table-new"><function>g_hash_table_new()</function></link> or <link linkend="g-hash-table-new-full"><function>g_hash_table_new_full()</function></link>.
<link linkend="GBytes"><type>GBytes</type></link> can also be used as keys in a <link linkend="GTree"><type>GTree</type></link> by passing the <link linkend="g-bytes-compare"><function>g_bytes_compare()</function></link>
function to <link linkend="g-tree-new"><function>g_tree_new()</function></link>.</para>
<para>The data pointed to by this bytes must not be modified. For a mutable
array of bytes see <link linkend="GByteArray"><type>GByteArray</type></link>. Use <link linkend="g-bytes-unref-to-array"><function>g_bytes_unref_to_array()</function></link> to create a
mutable array for a <link linkend="GBytes"><type>GBytes</type></link> sequence. To create an immutable <link linkend="GBytes"><type>GBytes</type></link> from
a mutable <link linkend="GByteArray"><type>GByteArray</type></link>, use the <link linkend="g-byte-array-free-to-bytes"><function>g_byte_array_free_to_bytes()</function></link> function.</para>
<para role="since">Since: <link linkend="api-index-2.32">2.32</link></para></refsect2>

</refsect1>

</refentry>
