mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-06-01 19:41:28 +00:00
bd9cd13058
Original commit message from CVS: * REQUIREMENTS: * docs/design/part-MT-refcounting.txt: * docs/design/part-clocks.txt: * docs/design/part-conventions.txt: * docs/design/part-gstobject.txt: * docs/design/part-relations.txt: * docs/design/part-standards.txt: * libs/gst/control/dparam.c: (gst_dparam_attach): * libs/gst/control/dparam.h: * libs/gst/control/dparammanager.c: (gst_dpman_add_required_dparam_callback), (gst_dpman_add_required_dparam_direct), (gst_dpman_add_required_dparam_array), (gst_dpman_attach_dparam), (gst_dpman_get_dparam), (gst_dpman_get_dparam_type), (gst_dpman_get_manager), (gst_dpman_bypass_dparam), (gst_dpman_preprocess_asynchronous), (gst_dpman_process_asynchronous), (gst_dpman_process_noop): * libs/gst/control/dparammanager.h: * testsuite/clock/clock2.c: (gst_clock_debug), (element_wait), (main): * testsuite/threads/signals.c: (run_thread), (main): * testsuite/threads/thread.c: (main): * tools/gst-launch.c: (fault_handler_sighandler), (fault_handler_sigaction), (fault_spin): Doc updates, Head backporting. Fix some testcases.
41 lines
1.3 KiB
Plaintext
41 lines
1.3 KiB
Plaintext
Ownership of dynamic objects
|
|
----------------------------
|
|
|
|
Any object-oriented system or language that doesn't have automatic garbage
|
|
collection has many potential pitfalls as far as the pointers go. Therefore,
|
|
some standards must be adhered to as far as who owns what.
|
|
|
|
Strings
|
|
-------
|
|
|
|
Arguments passed into a function are owned by the caller, and the function
|
|
will make a copy of the string for its own internal use. The string should
|
|
be const gchar *. Strings returned from a function are always a copy of the
|
|
original and should be freed after usage by the caller.
|
|
|
|
ex:
|
|
|
|
name = gst_element_get_name (element); /* copy of name is made */
|
|
.. use name ..
|
|
g_free (name); /* free after usage */
|
|
|
|
|
|
Objects
|
|
-------
|
|
|
|
Objects passed into a function are owned by the caller, any additional
|
|
reference held to the object after leaving the function should increase the
|
|
refcount of that object.
|
|
|
|
Objects returned from a function are owned by the caller. This means that the
|
|
called should _free() or _unref() the object after usage.
|
|
|
|
ex:
|
|
|
|
peer = gst_pad_get_peer (pad); /* peer with increased refcount */
|
|
if (peer) {
|
|
.. use peer ..
|
|
gst_object_unref (GST_OBJECT (peer)); /* unref peer after usage */
|
|
}
|
|
|