Method

GObjectObjectdup_data

since: 2.34

Declaration [src]

gpointer
g_object_dup_data (
  GObject* object,
  const gchar* key,
  GDuplicateFunc dup_func,
  gpointer user_data
)

Description [src]

This is a variant of g_object_get_data() which returns a ‘duplicate’ of the value. dup_func defines the meaning of ‘duplicate’ in this context, it could e.g. take a reference on a ref-counted object.

If the key is not set on the object then dup_func will be called with a NULL argument.

Note that dup_func is called while user data of object is locked.

This function can be useful to avoid races when multiple threads are using object data on the same key on the same object.

Available since: 2.34

This method is not directly available to language bindings.

Parameters

key

Type: const gchar*

A string, naming the user data pointer.

The data is owned by the caller of the method.
The value is a NUL terminated UTF-8 string.
dup_func

Type: GDuplicateFunc

Function to dup the value.

The argument can be NULL.
user_data

Type: gpointer

Passed as user_data to dup_func.

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

Return value

Type: gpointer

The result of calling dup_func on the value associated with key on object, or NULL if not set. If dup_func is NULL, the value is returned unmodified.

The returned data is owned by the instance.
The return value can be NULL.