Re: Zeroing out instance variables
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