unref_to_data


Description:

[ CCode ( array_length_type = "gsize" ) ]
public static uint8[] unref_to_data (owned Bytes bytes)

Unreferences the bytes, and returns a pointer the same byte data contents.

As an optimization, the byte data is returned without copying if this was the last reference to this and this was created with [ctor@GLib.Bytes.new], [ctor@GLib.Bytes.new_take] or [func@GLib.ByteArray.free_to_bytes] and the buffer was larger than the size [struct@GLib.Bytes] may internalize within its allocation. In all other cases the data is copied.

Parameters:

bytes

a [struct@GLib.Bytes]

size

location to place the length of the returned data

Returns:

a pointer to the same byte data, which should be freed with [func@GLib.free]