开发者

CFRelease vs CGPathRelease

开发者 https://www.devze.com 2023-02-17 00:56 出处:网络
The following is a snippet of code from the Omni frameworks: CGMutablePathRef开发者_运维百科 path = CGPathCreateMutable();

The following is a snippet of code from the Omni frameworks:

CGMutablePathRef开发者_运维百科 path = CGPathCreateMutable();
CGPathAddRect(path, NULL/*transform*/, rect);
self->_path = CGPathCreateCopy(path);
CFRelease(path);

Why is CFRelease used here instead of CGPathRelease? Are they the same, and if so, why does the latter exist?


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 *).

0

精彩评论

暂无评论...
验证码 换一张
取 消