• 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: Zeroing out instance variables
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Zeroing out instance variables


  • Subject: Re: Zeroing out instance variables
  • From: Ken Thomases <email@hidden>
  • Date: Sat, 17 Apr 2010 09:52:00 -0500

On Apr 17, 2010, at 9:35 AM, Jean-Daniel Dupas wrote:

> That said, this is an implementation details.
>
> IIRC, GnuStep used to store the retain count in 4 additional bytes allocated before each object.
>
> uint32_t *rc = (uint8_t *)self - 4;

Well, it's an implementation detail of which you have to be aware if you implement a custom allocator for objects (override -allocWithZone:), which I had suggested earlier in the thread.

If the retain count is either a traditional ivar (which it isn't) or is held externally, then you can do your own allocation and continue using the basic retain/release implementation.

If the retain count is expected to be in the allocated memory, even if it's before the instance address, then you have to override and reimplement -retain and -release if you override -allocWithZone:.

Regards,
Ken

_______________________________________________

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

References: 
 >Zeroing out instance variables (From: Ben Haller <email@hidden>)
 >Re: Zeroing out instance variables (From: Graham Cox <email@hidden>)
 >Re: Zeroing out instance variables (From: Ben Haller <email@hidden>)
 >Re: Zeroing out instance variables (From: "Paul Sanders" <email@hidden>)
 >Re: Zeroing out instance variables (From: Ben Haller <email@hidden>)
 >Re: Zeroing out instance variables (From: "Paul Sanders" <email@hidden>)
 >Re: Zeroing out instance variables (From: Ken Thomases <email@hidden>)
 >Re: Zeroing out instance variables (From: Jean-Daniel Dupas <email@hidden>)

  • Prev by Date: Re: Zeroing out instance variables
  • Next by Date: Re: Zeroing out instance variables
  • Previous by thread: Re: Zeroing out instance variables
  • Next by thread: Re: Zeroing out instance variables
  • Index(es):
    • Date
    • Thread