Function
GLibArraynew_take
since: 2.76
Declaration
GArray*
g_array_new_take (
gpointer data,
gsize len,
gboolean clear,
gsize element_size
)
Description
Creates a new GArray with data as array data, len 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 g_free().
In case the elements need to be cleared when the array is freed, use
g_array_set_clear_func() to set a GDestroyNotify function to perform
such task.
Do not use it if len or element_size are greater than G_MAXUINT.
GArray stores the length of its data in #guint, which may be shorter
than #gsize.
Available since: 2.76
This function is not directly available to language bindings.
Parameters
data-
Type: An array of
gpointerAn array of elements of
element_size, orNULLfor an empty array.The length of the array is specified in the lenargument. len-
Type:
gsizeThe number of elements in
data. clear-
Type:
gbooleanTRUEifGArrayelements should be automatically cleared to 0 when they are allocated. element_size-
Type:
gsizeThe size of each element in bytes.