### Function

# GLib ByteArray free_to_bytes

since: 2.32

#### Declaration [src]

    GBytes*
    g_byte_array_free_to_bytes (
      GByteArray* array
    )

#### Description [src]

Transfers the data from the `GByteArray` into a new immutable `GBytes`.

The `GByteArray` is freed unless the reference count of `array` is greater than one, the `GByteArray` wrapper is preserved but the size of `array` will be set to zero.

This is identical to using `g_bytes_new_take()` and `g_byte_array_free()` together.

Available since: 2.32

#### Parameters

`array`

  Type: An array of `guint8`

  A `GByteArray`.

  The called function takes ownership of the data, and is responsible for freeing it.

#### Return value

Type: `GBytes`

A new immutable `GBytes` representing same byte data that was in the array.

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