THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 16/04/2008 at 14:05, xxxxxxxx wrote:
User Information:
Cinema 4D Version: R9.1 +
Platform: Windows ; Mac ;
Language(s) : C++ ;
---------
I may not be entirely awake at the moment, but something that's not entirely clear to me is the subject of ownership after various InsertXX() methods...
For example, for BaseDocument::InsertObject() the SDK docs say:
"...The document takes over the ownership of the pointed object."
...which seems pretty clear that I don't have to (and in fact should not) Free() or gDelete (or have used an AutoAlloc) on the object pointer I'm passing to that routine (...right?).
But then you have other classes, like a GeListHead/GeListNode and the various InsertXXX() docs say:
"...The caller owns the pointed object"
...(similar usage also found for things like BaseObject::MakeTag() , BaseObject::MakeVariableTag() , BaseObject::InsertTag() , etc. ).
One would assume that C4D makes a copy/clone of the passed in pointer, so if I allocated it myself, I should also free it after doing the insertion... right? Except that in the case of BaseObject::MakeTag() and/or BaseObject::MakeVariableTag() , both of those actually create a tag on the object (no need to do an insertion), so clearly the object itself allocated it and knows about it, whereas with BaseObject::InsertTag() , it's more likely that the caller actually allocated the tag.
Is there some definitive answer in all cases ( "...The caller owns the pointed object" == caller is free to and should in fact free the object if done with it's own internal use of said object) ?
Thanks,
Keith