3

以下是来自Omni 框架的代码片段:

CGMutablePathRef path = CGPathCreateMutable();
CGPathAddRect(path, NULL/*transform*/, rect);
self->_path = CGPathCreateCopy(path);
CFRelease(path);

为什么这里使用 CFRelease 而不是 CGPathRelease?它们是否相同,如果是,为什么后者存在?

4

1 回答 1

4

From the documentation for CGPathRelease:

This function is equivalent to CFRelease, except that it does not cause an error if the path parameter is NULL.

In addition to not failing on NULL values, you also get a little bit of compile-time type-safety as the parameter is typed as CGPathRef rather than CFTypeRef (which is equivalent to void *).

于 2011-03-15T05:26:31.250 回答