How to properly issue CGMutablePathRef in -dealloc?

Problem: It may have CGMutablePathRefbeen created and installed, but it may not.

What I'm doing right now in -dealloc:

if (path != NULL) {
    CGPathRelease(path);
    path = NULL;
}

Is it correct?

+3
source share
1 answer

From the manual,

void CGPathRelease (Path CGPathRef);

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

Thus, there is no need to check for NULL.

+8
source

All Articles