Function

GLibPtrArraycopy

since: 2.62

Declaration

GPtrArray*
g_ptr_array_copy (
  GPtrArray* array,
  GCopyFunc func,
  gpointer user_data
)

Description

Makes a full (deep) copy of a GPtrArray.

func, as a GCopyFunc, takes two arguments, the data to be copied and a user_data pointer. On common processor architectures, it’s safe to pass NULL as user_data if the copy function takes only one argument. You may get compiler warnings from this though if compiling with GCC’s -Wcast-function-type warning.

If func is NULL, then only the pointers (and not what they are pointing to) are copied to the new GPtrArray.

The copy of array will have the same GDestroyNotify for its elements as array. The copy will also be NULL terminated if (and only if) the source array is.

Available since: 2.62

This function is not directly available to language bindings.

Parameters

array

Type: An array of gpointer

GPtrArray to duplicate.

The data is owned by the caller of the function.
func

Type: GCopyFunc

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

user_data

Type: gpointer

User data passed to the copy function func, or NULL.

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

Return value

Type: An array of gpointer

A deep copy of the initial GPtrArray.

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