mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-04-11 02:24:13 +00:00
object: add gst_clear_object()
This is based on g_clear_object(). Basically, you can use this instead of using g_object_unref (which needs to be preceded by a NULL-check). Fixes #275
This commit is contained in:
parent
e261c9534d
commit
c5793f82d3
2 changed files with 28 additions and 0 deletions
|
@ -295,6 +295,30 @@ gst_object_ref_sink (gpointer object)
|
|||
return g_object_ref_sink (object);
|
||||
}
|
||||
|
||||
/**
|
||||
* gst_clear_object: (skip)
|
||||
* @object_ptr: a pointer to a #GstObject reference
|
||||
*
|
||||
* Clears a reference to a #GstObject.
|
||||
*
|
||||
* @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
|
||||
* gst_object_unref() 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_object
|
||||
void
|
||||
gst_clear_object (volatile GstObject ** object_ptr)
|
||||
{
|
||||
g_clear_pointer (object_ptr, gst_object_unref);
|
||||
}
|
||||
|
||||
/**
|
||||
* gst_object_replace:
|
||||
* @oldobj: (inout) (transfer full) (nullable): pointer to a place of
|
||||
|
|
|
@ -254,6 +254,10 @@ gpointer gst_object_ref (gpointer object);
|
|||
GST_API
|
||||
void gst_object_unref (gpointer object);
|
||||
|
||||
GST_API
|
||||
void gst_clear_object (volatile GstObject **object_ptr);
|
||||
#define gst_clear_object(object_ptr) g_clear_pointer ((object_ptr), gst_object_unref)
|
||||
|
||||
GST_API
|
||||
gpointer gst_object_ref_sink (gpointer object);
|
||||
|
||||
|
|
Loading…
Reference in a new issue