Reputation: 153
Suppose I'm using CGColorSpaceRef
. I'm wondering if there is a difference between releasing the CGColorSpaceRef
by calling CFRelease
versus using CGColorSpaceRelease
?
i.e., a difference between this:
CGColorSpaceRef colorspace = CGColorSpaceCreateDeviceRGB();
// do stuff
CFRelease(colorspace);
versus doing:
CGColorSpaceRef colorspace = CGColorSpaceCreateDeviceRGB();
// do stuff
CGColorSpaceRelease(colorspace);
Upvotes: 1
Views: 683
Reputation: 43472
Either is acceptable. The second one will check for NULL
however, so it lets you skip a line of code. You must always check for NULL
before calling CFRelease()
. If you don't and NULL
is passed in, it will crash.
Upvotes: 2
Reputation: 5589
From the CGColorSpace Reference:
This function is equivalent to CFRelease, except that it does not cause an error if the cs parameter is NULL.
Upvotes: 5