• 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: [OT] Retain count riddle
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [OT] Retain count riddle


  • Subject: Re: [OT] Retain count riddle
  • From: Marcel Weiher <email@hidden>
  • Date: Tue, 30 Mar 2004 22:57:05 +0100

I prefer to put the entire accessor method into the macro. This avoids the issue and reduces your syntactic overhead even further, especially as you can have both the set and the get accessoor generated simultaneously.

See MPWFoundation/AccessorMacros.h


On 30 Mar 2004, at 22:00, Steve Stockman wrote:

On Mar 30, 2004, at 1:49 PM, Sailesh Agrawal wrote:
So I had this bug the other day that I thought would make an interesting
riddle.

The code looked like this:

#define SAFE_SET(old, new) [new retain]; [old release]; old = new;

Others have already pointed out the leak and the crash, but if you still want to use a macro, I would suggest redefining it as:

#define SAFE_SET(old,new) do { id _temp=[(new) retain]; [old release]; old=_temp; } while(0)



--
Marcel Weiher Metaobject Software Technologies
email@hidden www.metaobject.com
Metaprogramming for the Graphic Arts. HOM, IDEAs, MetaAd etc.
1d480c25f397c4786386135f8e8938e4
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.


References: 
 >[OT] Retain count riddle (From: "Sailesh Agrawal" <email@hidden>)
 >Re: [OT] Retain count riddle (From: Steve Stockman <email@hidden>)

  • Prev by Date: Re: BEST BOOK FOR LEARNING COCOA
  • Next by Date: graphs, pie and charts
  • Previous by thread: Re: [OT] Retain count riddle
  • Next by thread: Re: [OT] Retain count riddle
  • Index(es):
    • Date
    • Thread