Array.take


Description:

[ Version ( since = "2.76" ) ]
public Array.take (owned G[] data, bool clear = true, size_t element_size = sizeof ( G))

Creates a new `GArray` with data as array data, data.length as length and a reference count of 1.

This avoids having to copy the data manually, when it can just be inherited. After this call, data belongs to the `GArray` and may no longer be modified by the caller. The memory of data has to be dynamically allocated and will eventually be freed with [ func@GLib.free].

In case the elements need to be cleared when the array is freed, use [func@GLib.Array.set_clear_func] to set a [callback@GLib.DestroyNotify] function to perform such task.

Do not use it if data.length or element_size are greater than [`G_MAXUINT`](types.html#guint). `GArray` stores the length of its data in `guint`, which may be shorter than `gsize`.

Parameters:

data

an array of elements of element_size

clear

if true, `GArray` elements should be automatically cleared to 0 when they are allocated

element_size

the size of each element in bytes

len

the number of elements in data

Returns:

The new Array