uri: Add gst_clear_uri()

Basically, you can use this instead of using `gst_uri_unref()` (which
needs to be preceded by a NULL-check).

See https://gitlab.freedesktop.org/gstreamer/gstreamer/issues/275
and https://gitlab.freedesktop.org/gstreamer/gstreamer/merge_requests/3
This commit is contained in:
Niels De Graef 2019-05-10 14:51:15 +02:00
parent 19467a7d8d
commit 8d180557eb

View file

@ -392,6 +392,25 @@ gst_uri_unref (GstUri * uri)
gst_mini_object_unref (GST_MINI_OBJECT_CAST (uri));
}
/**
* gst_clear_uri: (skip)
* @uri_ptr: a pointer to a #GstUri reference
*
* Clears a reference to a #GstUri.
*
* @uri_ptr must not be %NULL.
*
* If the reference is %NULL then this function does nothing. Otherwise, the
* reference count of the uri is decreased and the pointer is set to %NULL.
*
* Since: 1.18
*/
static inline void
gst_clear_uri (GstUri ** uri_ptr)
{
gst_clear_mini_object ((GstMiniObject **) uri_ptr);
}
#ifdef G_DEFINE_AUTOPTR_CLEANUP_FUNC
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GstUri, gst_uri_unref)
#endif