• 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: Silence "potential leak warning" for create function?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Silence "potential leak warning" for create function?


  • Subject: Re: Silence "potential leak warning" for create function?
  • From: Luke Scott <email@hidden>
  • Date: Tue, 17 May 2011 13:12:59 -0700
  • Thread-topic: Silence "potential leak warning" for create function?

On 5/17/11 1:01 PM, "Gerd Knops" <email@hidden> wrote:


>
>On May 17, 2011, at 2:50 PM, Luke Scott wrote:
>
>> Given the following code (as an example):
>>
>> - (CGImageRef)createImage
>> {
>>     CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
>>
>>     CGContextRef context = CGBitmapContextCreate(NULL,
>>                                                  100,
>>                                                  100,
>>                                                  8,
>>                                                  0,
>>                                                  colorSpace,
>>
>>kCGBitmapByteOrder32Little | kCGImageAlphaNoneSkipFirst);
>>
>>     CGImageRef imageRef = CGBitmapContextCreateImage(context);
>>
>>     CGContextRelease(context);
>>     CGColorSpaceRelease(colorSpace);
>>
>>     return imageRef;
>> }
>>
>> - (void)someFunction
>> {
>>     CGImageRef image = [self createImage];
>>
>>     CGImageRelease(image);
>> }
>>
>>
>> I get "Potential leak of an object" on "return imageRef;" and
>>"Incorrect decrement of the reference count" on "CGImageRelease(image)".
>>
>> How do I tell Xcode that "createImage" is a "create" function and that
>>it's passing responsibility of releasing what is returned to the caller?
>>
>In ObjcC a "new" prefix behaves like a "create" prefix in the Carbon
>world.  So changing "-createImage" to "-newImage" should do the trick.
>
>Gerd

That did it, thanks!

Luke Scott


 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

References: 
 >Re: Silence "potential leak warning" for create function? (From: Gerd Knops <email@hidden>)

  • Prev by Date: Re: Silence "potential leak warning" for create function?
  • Next by Date: Compiling in Xcode 4 For OS X 10.4 and 10.5
  • Previous by thread: Re: Silence "potential leak warning" for create function?
  • Next by thread: Compiling in Xcode 4 For OS X 10.4 and 10.5
  • Index(es):
    • Date
    • Thread