这很奇怪.在技术问答中,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)
在这里打电话?