Function

GLibListcopy_deep

since: 2.34

Declaration [src]

GList*
g_list_copy_deep (
  GList* list,
  GCopyFunc func,
  gpointer user_data
)

Description [src]

Makes a full (deep) copy of a GList.

In contrast with g_list_copy(), this function uses func to make a copy of each list element, in addition to copying the list container itself.

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.

For instance, if list holds a list of GObjects, you can do:

another_list = g_list_copy_deep (list, (GCopyFunc) g_object_ref, NULL);

And, to entirely free the new list, you could do:

g_list_free_full (another_list, g_object_unref);

Available since: 2.34

This function is not directly available to language bindings.

Parameters

list

Type: A list of gpointer

A GList, this must point to the top of the list.

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

Type: GCopyFunc

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

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: A list of gpointer

The start of the new list that holds a full copy of list, use g_list_free_full() to free it.

The data is owned by the called function.