cogl/object: add cogl_clear_object utility function

This is based on `g_clear_object`, so it will be a bit more consistent
to write (and prevents the headaches from accidentally forgetting a NULL
check).
This commit is contained in:
Niels De Graef 2018-11-15 13:01:59 +01:00
parent 63a6ead7d9
commit 081842bac6

View File

@ -75,6 +75,20 @@ cogl_object_ref (void *object);
void void
cogl_object_unref (void *object); cogl_object_unref (void *object);
/**
* cogl_clear_object: (skip)
* @object_ptr: a pointer to a #CoglObject reference
*
* Clears a reference to a #CoglObject.
*
* @object_ptr must not be %NULL.
*
* If the reference is %NULL then this function does nothing.
* Otherwise, the reference count of the object is decreased using
* cogl_object_unref() and the pointer is set to %NULL.
*/
#define cogl_clear_object(object_ptr) g_clear_pointer ((object_ptr), cogl_object_unref)
/** /**
* CoglUserDataKey: * CoglUserDataKey:
* @unused: ignored. * @unused: ignored.