Function
GLibPtrArraynew_take_null_terminated
since: 2.76
Declaration [src]
GPtrArray*
g_ptr_array_new_take_null_terminated (
gpointer* data,
GDestroyNotify element_free_func
)
Description [src]
Creates a new GPtrArray
with data
as pointers, computing the length of it
and setting the reference count to 1.
This avoids having to copy such data manually.
After this call, data
belongs to the GPtrArray
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.
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 the data
length 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
gpointer
An array of pointers,
NULL
terminated, orNULL
for an empty array.The argument can be NULL
.The array must be NULL
-terminated.The called function takes ownership of the data, and is responsible for freeing it. element_free_func
-
Type:
GDestroyNotify
A function to free elements on
array
destruction orNULL
.