[gst-devel] How to handle the memory allocation after gst_caps_new_simple? How to use gst_caps_unref(caps) about this cases?

xiupeng xie xiexiupeng at gmail.com
Mon Feb 16 02:14:17 CET 2009


 Hi All, i have one question about
How to handle the memory allocation after gst_caps_new_simple? How to use
gst_caps_unref(caps) about this cases?

>From GstCaps spec, Setting this property takes a reference to the supplied
GstCaps object,

I think this comment didn't mention that it will free this object if there
is no chance for
g_object_unref<http://library.gnome.org/devel/gobject/unstable/gobject-The-Base-Object-Type.html#g-object-unref>()
being called even under gobject memory framework.



For example, let 0x12345678 as the address of new allocated GstCaps object
in your bbpack. We consider two approach:



1.approach:

GstCaps *caps;

Caps = gst_caps_new_simple(....);  // for example, let 0x12345678 be the
address of memory.

g_object_set(G_OBJECT(caps_filter), "caps", Caps // it will be 0x12345678.

gst_caps_unref(caps); // the purpose of caps has finished, since the all
detailed parameter  under property "caps" of "caps_filter" has been
assigned.
For case1, distinctly we have to call gst_caps_unref() to release?



2.approach:
don't use local pointer,

g_object_set(G_OBJECT(caps_filter), "caps", gst_caps_new_simple(....), // it
will also 0x12345678.



In above two cases, 3rd parameter will always be 0x12345678 during runtime.

g_object_set(,, 0x12345678.)



In case 2, How can your codes to notify g_object_set() to call
g_object_unref<http://library.gnome.org/devel/gobject/unstable/gobject-The-Base-Object-Type.html#g-object-unref>()
so that to release this memory?

Would you please judge which approach is correct? and why? thanks in
advance.

Xiupeng.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/gstreamer-devel/attachments/20090216/68de2513/attachment.htm>


More information about the gstreamer-devel mailing list