gstreamer/docs/design/part-standards.txt
Erik Walthinsen c824d8eaf9 current set of design docs, in .txt format
Original commit message from CVS:
current set of design docs, in .txt format
2001-01-20 20:08:59 +00:00

17 lines
1 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 remain the property of the
function called, and the caller must make a copy if it is to use the string for an extended duration.
Objects:
The ownership of an object during a function call depends on the type of function. If the function is simply returning
something from the object, such as _get_name(), the caller retains ownership. If the object passed is to be
manipulated in some way, it is generally the case that the function will take over the ownership. This should be
expressed as a reference increment on that object, but isn't in the general case (yet).