summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNiels De Graef <Niels.DeGraef@barco.com>2018-11-15 13:01:59 +0100
committerNiels De Graef <Niels.DeGraef@barco.com>2018-11-20 15:25:24 +0100
commit081842bac6aa0532f885490f795ce113c383cb5f (patch)
treeaf54c4d04eb5b0c5376f69d355fcd85421c9c1c1
parent63a6ead7d9449c10fdaeebcc3e13282dc70c1e23 (diff)
downloadmutter-081842bac6aa0532f885490f795ce113c383cb5f.tar.gz
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).
-rw-r--r--cogl/cogl/cogl-object.h14
1 files changed, 14 insertions, 0 deletions
diff --git a/cogl/cogl/cogl-object.h b/cogl/cogl/cogl-object.h
index 338ef79d8..91ef5790d 100644
--- a/cogl/cogl/cogl-object.h
+++ b/cogl/cogl/cogl-object.h
@@ -76,6 +76,20 @@ void
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:
* @unused: ignored.
*