unref_to_array


Description:

public static ByteArray unref_to_array (owned Bytes bytes)

Unreferences the bytes, and returns a new mutable ByteArray 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 Bytes, Bytes.take or free_to_bytes. In all other cases the data is copied.

Do not use it if this contains more than g_maxuint bytes. ByteArray stores the length of its data in uint, which may be shorter than size_t, that this is using.

Parameters:

bytes

a Bytes

Returns:

a new mutable ByteArray containing the same byte data