YetAnotherForum
Welcome Guest Search | Active Topics | Log In | Register

which null operations should appear in Finalize's function?
user2016
#1 Posted : Saturday, June 04, 2016 8:45:04 AM(UTC)
Rank: Newbie

Groups: Registered
Joined: 6/4/2016(UTC)
Posts: 6

Thanks: 0 times
Was thanked: 0 time(s) in 0 post(s)
Dear author, I have known that null operations are to break up the circular reference, but which null operations should appear in Finalize's function? For the question, I am very puzzled. Can you tell me some principle? Thank you very much.

void SQClosure:Finalize(){
SQFunctionProto *f = _function;
_NULL_SQOBJECT_VECTOR(_outervalues,f->_noutervalues);
_NULL_SQOBJECT_VECTOR(_defaultparams,f->_ndefaultparams);
}

void SQFunctionProto::Finalize(){ _NULL_SQOBJECT_VECTOR(_literals,_nliterals); }
fagiano
#2 Posted : Saturday, June 04, 2016 9:33:19 AM(UTC)
Rank: Advanced Member

Groups: Registered, Administrators
Joined: 6/11/2005(UTC)
Posts: 1,054

Thanks: 0 times
Was thanked: 77 time(s) in 59 post(s)
Dear user :) ,
The only variables that need to be nulled are the one that can participate to a reference cycle. The ones that can possibly refer to types that have references of their own(tables,class instances,closures etc...).

ciao
Alberto
Follow me on Twitter @squirrellang
user2016
#3 Posted : Sunday, June 05, 2016 12:37:44 PM(UTC)
Rank: Newbie

Groups: Registered
Joined: 6/4/2016(UTC)
Posts: 6

Thanks: 0 times
Was thanked: 0 time(s) in 0 post(s)
Why should _functions in class SQFunctionProto not be nulled when invoking function "Finalize"? the _functions is type SQObjectPtr* which participates in the computation of "circular reference.
fagiano
#4 Posted : Monday, June 06, 2016 9:31:50 AM(UTC)
Rank: Advanced Member

Groups: Registered, Administrators
Joined: 6/11/2005(UTC)
Posts: 1,054

Thanks: 0 times
Was thanked: 77 time(s) in 59 post(s)
SQFunctionProto only has references to literals (integers,floats,bools and strings) so there are not cycles possible.

ciao
Alberto
Follow me on Twitter @squirrellang
user2016
#5 Posted : Monday, June 06, 2016 1:23:58 PM(UTC)
Rank: Newbie

Groups: Registered
Joined: 6/4/2016(UTC)
Posts: 6

Thanks: 0 times
Was thanked: 0 time(s) in 0 post(s)
Dear author, "SQFunctionProto only has references to literals (integers,floats,bools and strings)", which code can be understood about the point?
Thank you for your help.
Users browsing this topic
Guest
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

Clean Slate theme by Jaben Cargman (Tiny Gecko)
Powered by YAF 1.9.4 | YAF © 2003-2010, Yet Another Forum.NET
This page was generated in 0.079 seconds.