Array.take_zero_terminated


Description:

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

Creates a new Array with data as array data, computing the length of it and setting the reference count to 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.

The length is calculated by iterating through data until the first null element is found.

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

clear

true if Array elements should be automatically cleared to 0 when they are allocated

element_size

the size of each element in bytes

Returns:

A new Array