Function

GLibPtrArraynew_from_null_terminated_array

since: 2.76

Declaration [src]

GPtrArray*
g_ptr_array_new_from_null_terminated_array (
  gpointer* data,
  GCopyFunc copy_func,
  gpointer copy_func_user_data,
  GDestroyNotify element_free_func
)

Description [src]

Creates a new GPtrArray copying the pointers from data after having computed the length of it and with a reference count of 1. This avoids having to manually add each element one by one. If copy_func is provided, then it is used to copy the data in the new array. It also set 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 has more than G_MAXUINT elements. 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; or NULL for an empty array.

The argument can be NULL.
The array must be NULL-terminated.
The data is owned by the caller of the function.
copy_func

Type: GCopyFunc

A copy function used to copy every element in the array or NULL.

copy_func_user_data

Type: gpointer

User data passed to copy_func, or NULL.

The argument can be NULL.
The data is owned by the caller of the function.
element_free_func

Type: GDestroyNotify

A function to free elements on array destruction or NULL.

Return value

Type: An array of gpointer

A new GPtrArray.

The caller of the function takes ownership of the data, and is responsible for freeing it.