### Method

# GLib Bytes unref_to_array

since: 2.32

#### Declaration

    GByteArray*
    g_bytes_unref_to_array (
      GBytes* bytes
    )

#### Description

Unreferences the bytes, and returns a new mutable `GByteArray` containing the same byte data.

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 g_bytes_new(), `g_bytes_new_take()` or g_byte_array_free_to_bytes(). In all other cases the data is copied.

Do not use it if `bytes` contains more than `G_MAXUINT` bytes. `GByteArray` stores the length of its data in #guint, which may be shorter than #gsize, that `bytes` is using.

Available since: 2.32

#### Return value

Type: An array of `guint8`

A new mutable `GByteArray` containing the same byte data.

The caller of the method takes ownership of the data, and is responsible for freeing it.