• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: ARC + return of autoreleased CFType
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: ARC + return of autoreleased CFType


  • Subject: Re: ARC + return of autoreleased CFType
  • From: Matt Neuburg <email@hidden>
  • Date: Wed, 15 Feb 2012 20:55:57 -0800

On Thu, 20 Oct 2011 17:38:03 -0400, Bill Cheeseman <email@hidden> said:
>
>Specifically, if your Cocoa method returns a CFTypeRef object retained, and you don't put "Copy" or "Create" in the method name, Analyze reports a "potential" memory leak. Go back and insert "Copy" or "Create" into the method name, and Analyze no longer reports a potential memory leak. To me, it makes all the sense in the world to apply the "create rule" to Cocoa methods that return Core Foundation CFTypeRef objects.

I just tried that it and it didn't help:

- (CGContextRef) bitmapContextCreate:(CGSize)size {
	int bitmapBytesPerRow = (size.width * 4);
	bitmapBytesPerRow += (16 - bitmapBytesPerRow);
	CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
        CGContextRef context = NULL;
	context = CGBitmapContextCreate(NULL, size.width, size.height,
            8, bitmapBytesPerRow, colorSpace, kCGImageAlphaPremultipliedLast);
	CGColorSpaceRelease(colorSpace);
        return context;
}

As long as I am returning a context obtained with CGBitmapContextCreate and not autoreleased, it doesn't matter what I name the method: the analyzer is unhappy. And under ARC it isn't clear what I can do about this, since I can't autorelease anything and I can't invite ARC to do so (and anyway I don't want to). Only adding CF_RETURNS_RETAINED quieted the analyzer. m.

--
matt neuburg, phd = email@hidden, <http://www.apeth.net/matt/>
A fool + a tool + an autorelease pool = cool!
Programming iOS 5! http://shop.oreilly.com/product/0636920023562.do
_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden


  • Prev by Date: Re: Custom UIView drawing but can't figure out when/where it's loading
  • Next by Date: Creating a file using NSURL
  • Previous by thread: Re: __block __weak - am I doing this right?
  • Next by thread: Creating a file using NSURL
  • Index(es):
    • Date
    • Thread