Function

GLibPtrArraynew_null_terminated

since: 2.74

Declaration [src]

GPtrArray*
g_ptr_array_new_null_terminated (
  guint reserved_size,
  GDestroyNotify element_free_func,
  gboolean null_terminated
)

Description [src]

Like g_ptr_array_new_full() but also allows to set the array to be NULL terminated. A NULL terminated pointer array has an additional NULL pointer after the last element, beyond the current length.

GPtrArray created by other constructors are not automatically NULL terminated.

Note that if the arrays length is zero and currently no data array is allocated, then pdata will still be NULL. %GPtrArray will only NULL terminate pdata, if an actual array is allocated. It does not guarantee that an array is always allocated. In other words, if the length is zero, then pdata may either point to a NULL terminated array of length zero or be NULL.

Available since: 2.74

This function is not directly available to language bindings.

Parameters

reserved_size

Type: guint

Number of pointers preallocated. If null_terminated is TRUE, the actually allocated buffer size is reserved_size plus 1, unless reserved_size is zero, in which case no initial buffer gets allocated.

element_free_func

Type: GDestroyNotify

A function to free elements with destroy array or NULL.

null_terminated

Type: gboolean

Whether to make the array as NULL terminated.

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.