0

如果我在 C++ 代码中创建一个对象并在 ActionScript 代码中返回它,我应该在返回它之前调用 AS3_Release 吗?例如,我在 *.gg 文件中有函数:

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;
}

我应该调用AS3_ReleaseobjDestByteArray变量result吗?

4

1 回答 1

1

所有唯一AS3_Val变量最终都需要被释放。对于AS3_Val返回变量,该函数不会释放值本身,而是假定其调用者将安排该值的最终释放。

因此,在您的示例中,发布objDestByteArray但尚未发布result。调用makeThumbnail者负责释放其返回值。

于 2011-02-01T18:21:43.417 回答