• 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: Calling a Cocoa library from C
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Calling a Cocoa library from C


  • Subject: Re: Calling a Cocoa library from C
  • From: Greg Parker <email@hidden>
  • Date: Mon, 14 Nov 2011 11:22:21 -0800

On Nov 12, 2011, at 2:29 AM, Jean-Daniel Dupas wrote:
> Le 12 nov. 2011 à 03:34, Charles Srstka a écrit :
>>
>> In this day and age, you should probably just use @autoreleasepool instead of NSAutoreleasePool:
>>
>> int get_float_data(float *result1, float *result2)
>> {
>> 	@autoreleasepool {
>> 		[objcCode call];
>> 		*result1 = [more stuff];
>> 		etc.;
>> 	}
>>
>> 	return blahblah;
>> }
>
>
> Note that this code is not equivalent with the previous one. @autoreleasepool does not drain on exception.

Incorrect. @autoreleasepool does everything that NSAutoreleasePool does on exceptions. (In fact, @autoreleasepool fixes a small leak that NSAutoreleasePool suffers.)

You may be thinking of ARC. ARC is expected to leak on exceptions unless you pass a special compiler flag. @autoreleasepool does not require ARC.


--
Greg Parker     email@hidden     Runtime Wrangler


_______________________________________________

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

  • Follow-Ups:
    • Re: Calling a Cocoa library from C
      • From: Ken Thomases <email@hidden>
References: 
 >Calling a Cocoa library from C (From: Nathan Sims <email@hidden>)
 >Re: Calling a Cocoa library from C (From: Wim Lewis <email@hidden>)
 >Re: Calling a Cocoa library from C (From: Charles Srstka <email@hidden>)
 >Re: Calling a Cocoa library from C (From: Jean-Daniel Dupas <email@hidden>)

  • Prev by Date: Re: Calling a Cocoa library from C
  • Next by Date: Re: Calling a Cocoa library from C
  • Previous by thread: Re: Calling a Cocoa library from C
  • Next by thread: Re: Calling a Cocoa library from C
  • Index(es):
    • Date
    • Thread