Function

GLibdatalist_id_dup_data

Declaration [src]

gpointer
g_datalist_id_dup_data (
  GData** datalist,
  GQuark key_id,
  GDuplicateFunc dup_func,
  gpointer user_data
)

Description [src]

This is a variant of g_datalist_id_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_id is not set in the datalist then dup_func will be called with a NULL argument.

Note that dup_func is called while the datalist is locked, so it is not allowed to read or modify the datalist.

This function can be useful to avoid races when multiple threads are using the same datalist and the same key.

Available since:2.34

Parameters

datalist GData
 

Location of a datalist.

 The data is owned by the caller of the function.
key_id GQuark
 

The GQuark identifying a data element.

dup_func GDuplicateFunc
 

Function to duplicate the old value.

user_data gpointer
 

Passed as user_data to dup_func.

Return value

Returns: gpointer
 

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