From 8d180557ebce95e03eb2aece0aef52fb46a67338 Mon Sep 17 00:00:00 2001 From: Niels De Graef Date: Fri, 10 May 2019 14:51:15 +0200 Subject: [PATCH] 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 --- gst/gsturi.h | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/gst/gsturi.h b/gst/gsturi.h index 75145f9a62..277a10531a 100644 --- a/gst/gsturi.h +++ b/gst/gsturi.h @@ -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