相关疑难解决方法(0)

为什么我必须释放这些数据?我是老板吗?

这很奇怪.在技术问答中,Apple说:

void *data = CGBitmapContextGetData (cgctx);
if (data != NULL)
{

    // **** You have a pointer to the image data ****

    // **** Do stuff with the data here ****

}

// When finished, release the context
CGContextRelease(cgctx); 
// Free image data memory for the context
if (data)
{
    free(data);
}
Run Code Online (Sandbox Code Playgroud)

我查阅了CGBitmapContextGetData的文档,并没有提到我在调用它时负责释放数据.已经有CGContextRelease调用来清理上下文.

必须在上下文中额外释放数据有什么意义?它只是指向该数据的指针,对吧?他们为什么free(data)在这里打电话?

memory-management core-graphics objective-c ios

7
推荐指数
1
解决办法
1384
查看次数