Jump to content

  • Log In with Google      Sign In   
  • Create Account


- - - - -

CScriptAny leaking?


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
2 replies to this topic

#1 bollµ   Members   -  Reputation: 354

Like
0Likes
Like

Posted 23 February 2013 - 10:49 PM

I've been writing a generalized voidPtr class for angelScript, because in many cases,I won't know the type of the object I'm sending, hence I'll have to cast the object based on what the other person decides to retrieve. So, I've been looking though cScriptAny.

 

 cScriptAny's Store() function does this:

 

 

 

else if( value.typeId & asTYPEID_MASK_OBJECT )
    {
        // Create a copy of the object
        value.valueObj = engine->CreateScriptObjectCopy(ref, value.typeId);
    }
 

 

Now, in retrieve, it does this:

 

 

 

else if( refTypeId & asTYPEID_MASK_OBJECT )
    {
        // Is the object type compatible with the stored value?


        // Copy the object into the given reference
        if( value.typeId == refTypeId )
        {
            engine->AssignScriptObject(ref, value.valueObj, value.typeId);


            return true;
        }
    }
 

 

 

So, isn't cScriptAny leaking the middleman object that was created within the cScriptAny class by calling CreateScriptObjectCopy?

Why is the class not freeing that copy? shouldn't there be a call to ReleaseScriptObject after calling AssignScriptObject?

 

I'm quite sure I'm missing something, but I'm not sure what :D

 

Thanks!

~Bollu


a WIP 2d game engine: https://code.google.com/p/modulusengine/

English is not my first language, so do feel free to correct me :)


Sponsor:

#2 TheAtom   Members   -  Reputation: 330

Like
0Likes
Like

Posted 24 February 2013 - 12:22 AM

On storing of an object, CScriptAny will hold the copy of that object. On retrieval, the copy is assigned to the argument passed by reference (which involves making another copy), and CScriptAny still holds the first copy. No freeing should happen at that point.

 

The copy of the object held by CScriptAny is freed when either another object is stored in it, or when CScriptAny is destroyed.



#3 bollµ   Members   -  Reputation: 354

Like
0Likes
Like

Posted 24 February 2013 - 12:57 AM

Ah, thanks! that makes sense :)


a WIP 2d game engine: https://code.google.com/p/modulusengine/

English is not my first language, so do feel free to correct me :)





Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS