If I create an object in C++ code and return it in ActionScript code should I call AS3_Release before returning it? For example, I have the function in the *.gg file:
public function makeThumbnail(...): Object
{
AS3_Val objDestByteArray = AS3_New(ByteArray_class, no_params);
int intDestWidth;
int intDestHeight;
// ... make some calculations and set results as object properties
AS3_Val result = AS3_Object("width:IntType, height:IntType, data:AS3ValType", intDestWidth, intDestHeight, objDestByteArray);
// Do I need to call this?
//AS3_Release(objDestByteArray);
//AS3_Release(result);
return result;
}
Should I call AS3_Release
for objDestByteArray
and result
variables?
All unique AS3_Val
variables need to be released eventually. For AS3_Val
return variables, the function doesn't release the value itself but instead assumes that its caller will arrange for the value's eventual release.
So in your example, release objDestByteArray
but don't release result
yet. Whoever is calling makeThumbnail
is responsible for releasing its return value.