mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-02-17 03:35:21 +00:00
Add helper function to set GstObject pointers with proper ref/unref sequence.
Original commit message from CVS: Add helper function to set GstObject pointers with proper ref/unref sequence.
This commit is contained in:
parent
1bce047ddc
commit
6f2ff2f81e
2 changed files with 23 additions and 0 deletions
|
@ -228,6 +228,27 @@ gst_object_sink (GstObject *object)
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* gst_object_swap:
|
||||
* @oldobj: pointer to place of old GstObject
|
||||
* @newobj: new GstObject
|
||||
*
|
||||
* Unrefs the object pointer to by oldobj, refs the newobj and
|
||||
* puts the newobj in *oldobj.
|
||||
*/
|
||||
void
|
||||
gst_object_swap (GstObject **oldobj, GstObject *newobj)
|
||||
{
|
||||
if (*oldobj != newobj) {
|
||||
if (newobj)
|
||||
gst_object_ref (newobj);
|
||||
if (*oldobj)
|
||||
gst_object_unref (*oldobj);
|
||||
|
||||
*oldobj = newobj;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* gst_object_destroy:
|
||||
* @object: GstObject to destroy
|
||||
|
|
|
@ -146,6 +146,8 @@ void gst_object_restore_thyself (GstObject *object, xmlNodePtr self);
|
|||
GstObject * gst_object_ref (GstObject *object);
|
||||
void gst_object_unref (GstObject *object);
|
||||
void gst_object_sink (GstObject *object);
|
||||
|
||||
void gst_object_swap (GstObject **oldobj, GstObject *newobj);
|
||||
/* destroying an object */
|
||||
void gst_object_destroy (GstObject *object);
|
||||
|
||||
|
|
Loading…
Reference in a new issue