Function
GLibPtrArraynew_from_array
since: 2.76
Declaration [src]
GPtrArray*
g_ptr_array_new_from_array (
gpointer* data,
gsize len,
GCopyFunc copy_func,
gpointer copy_func_user_data,
GDestroyNotify element_free_func
)
Description [src]
Creates a new GPtrArray, copying len pointers from data, and setting
the array’s reference count to 1.
This avoids having to manually add each element one by one.
If copy_func is provided, then it is used to copy each element before
adding them to the new array. If it is NULL then the pointers are copied directly.
It also sets element_free_func for freeing each element when the array is
destroyed either via g_ptr_array_unref(), when g_ptr_array_free() is called
with free_segment set to TRUE or when removing elements.
Do not use it if len is greater than G_MAXUINT. GPtrArray
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 pointers, or
NULLfor an empty array.The argument can be NULL.The length of the array is specified in the lenargument.The data is owned by the caller of the function. len-
Type:
gsizeThe number of pointers in
data. copy_func-
Type:
GCopyFuncA copy function used to copy every element in the array or
NULL. copy_func_user_data-
Type:
gpointerUser data passed to
copy_func, orNULL.The argument can be NULL.The data is owned by the caller of the function. element_free_func-
Type:
GDestroyNotifyA function to free elements on
arraydestruction orNULL.