mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-25 11:11:08 +00:00
structure: add gst_clear_structure()
Basically, you can use this instead of using gst_structure_free (which needs to be preceded by a NULL-check). Also fixes #275
This commit is contained in:
parent
fdeddb4b93
commit
e35dc31fda
2 changed files with 28 additions and 0 deletions
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
Loading…
Reference in a new issue