开发者

Should i release return object from CGImageSourceCopyPropertiesAtIndex call?

开发者 https://www.devze.com 2023-01-01 07:39 出处:网络
It\'s not stated in documentation for CGImageSource开发者_开发知识库CopyPropertiesAtIndex function. But am i right that i should call CFRelease on retured CFDictionaryRef ?

It's not stated in documentation for CGImageSource开发者_开发知识库CopyPropertiesAtIndex function. But am i right that i should call CFRelease on retured CFDictionaryRef ?

Quick sample:

NSDictionary* metadata = (NSDictionary   *)CGImageSourceCopyPropertiesAtIndex(source,0,NULL);
......................
//Should i call CFRelease(metadata); ??

Thanks.


Yes you should release it. It doesn't say it in the documentation because it's a general convention. Every object returned by a function with Copy or Create in its name is owned by you and should be released when you're done.


For GC, you can do this too:

(NSDictionary *)NSMakeCollectable( CGImageSourceCopyPropertiesAtIndex(sourceRef, 0, (CFDictionaryRef)options) );
0

精彩评论

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