Function
GLibdatalist_id_replace_data
since: 2.34
Declaration [src]
gboolean
g_datalist_id_replace_data(
GData**datalist,
GQuarkkey_id,
gpointeroldval,
gpointernewval,
GDestroyNotifydestroy,
GDestroyNotify*old_destroy
)
Description [src]
Compares the member that is associated with key_id in
datalist to oldval, and if they are the same, replace
oldval with newval.
This is like a typical atomic compare-and-exchange
operation, for a member of datalist.
If the previous value was replaced then ownership of the
old value (oldval) is passed to the caller, including
the registered destroy notify for it (passed out in old_destroy).
Its up to the caller to free this as they wish, which may
or may not include using old_destroy as sometimes replacement
should not destroy the object in the normal way.
Available since: 2.34
This function is not directly available to language bindings.
Parameters
datalist-
Type:
GDataLocation of a datalist.
The data is owned by the caller of the function. key_id-
Type:
GQuarkThe
GQuarkidentifying a data element. oldval-
Type:
gpointerThe old value to compare against.
The argument can beNULL.The data is owned by the caller of the function. newval-
Type:
gpointerThe new value to replace it with.
The argument can beNULL.The data is owned by the caller of the function. destroy-
Type:
GDestroyNotifyDestroy notify for the new value.
The argument can beNULL. old_destroy-
Type:
GDestroyNotifyDestroy notify for the existing value.
The argument will be set by the function.The argument can beNULL.The returned data is owned by the function.
Return value
Type: gboolean
TRUE if the existing value for key_id was replaced
by newval, FALSE otherwise.