diff --git a/gst/gststructure.c b/gst/gststructure.c index 734b2d27f6..dae2b63b6a 100644 --- a/gst/gststructure.c +++ b/gst/gststructure.c @@ -394,6 +394,30 @@ gst_structure_free (GstStructure * structure) g_slice_free1 (sizeof (GstStructureImpl), structure); } +/** + * gst_clear_structure: (skip) + * @structure_ptr: a pointer to a #GstStructure reference + * + * Clears a reference to a #GstStructure. + * + * @structure_ptr must not be %NULL. + * + * If the reference is %NULL then this function does nothing. + * Otherwise, the structure is free'd using gst_structure_free() and the + * pointer is set to %NULL. + * + * A macro is also included that allows this function to be used without + * pointer casts. + * + * Since: 1.16 + **/ +#undef gst_clear_structure +void +gst_clear_structure (volatile GstStructure ** structure_ptr) +{ + g_clear_pointer (structure_ptr, gst_structure_free); +} + /** * gst_structure_get_name: * @structure: a #GstStructure diff --git a/gst/gststructure.h b/gst/gststructure.h index e366fea36f..624b6e6cb6 100644 --- a/gst/gststructure.h +++ b/gst/gststructure.h @@ -133,6 +133,10 @@ gboolean gst_structure_set_parent_refcount (GstStructure * GST_API void gst_structure_free (GstStructure * structure); +GST_API +void gst_clear_structure (volatile GstStructure **structure_ptr); +#define gst_clear_structure(structure_ptr) g_clear_pointer ((structure_ptr), gst_structure_free) + GST_API const gchar * gst_structure_get_name (const GstStructure * structure);