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 Array 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 Array and may no longer be modified by the caller. The memory of data has to be dynamically allocated and will eventually be freed with g_free.

In case the elements need to be cleared when the array is freed, use set_clear_func to set a DestroyNotify function to perform such task.

Do not use it if data.length or element_size are greater than g_maxuint. Array stores the length of its data in uint , which may be shorter than size_t.

Parameters:

data

an array of elements of element_size, or null for an empty array

clear

true if Array 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:

A new Array