mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-25 17:50:36 +00:00
miniobject: add gst_clear_mini_object()
This is based on g_clear_object(). Basically, you can use this instead of using gst_mini_object_unref (which needs to be preceded by a NULL-check). Also fixes #275
This commit is contained in:
parent
c5793f82d3
commit
7e69305657
2 changed files with 28 additions and 0 deletions
|
@ -668,6 +668,30 @@ gst_mini_object_unref (GstMiniObject * mini_object)
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* gst_clear_mini_object: (skip)
|
||||
* @object_ptr: a pointer to a #GstMiniObject reference
|
||||
*
|
||||
* Clears a reference to a #GstMiniObject.
|
||||
*
|
||||
* @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_mini_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_mini_object
|
||||
void
|
||||
gst_clear_mini_object (volatile GstMiniObject ** object_ptr)
|
||||
{
|
||||
g_clear_pointer (object_ptr, gst_mini_object_unref);
|
||||
}
|
||||
|
||||
/**
|
||||
* gst_mini_object_replace:
|
||||
* @olddata: (inout) (transfer full) (nullable): pointer to a pointer to a
|
||||
|
|
|
@ -234,6 +234,10 @@ GstMiniObject * gst_mini_object_ref (GstMiniObject *mini_object);
|
|||
GST_API
|
||||
void gst_mini_object_unref (GstMiniObject *mini_object);
|
||||
|
||||
GST_API
|
||||
void gst_clear_mini_object (volatile GstMiniObject **object_ptr);
|
||||
#define gst_clear_mini_object(object_ptr) g_clear_pointer ((object_ptr), gst_mini_object_unref)
|
||||
|
||||
GST_API
|
||||
void gst_mini_object_weak_ref (GstMiniObject *object,
|
||||
GstMiniObjectNotify notify,
|
||||
|
|
Loading…
Reference in a new issue