Re: nil pointers
Re: nil pointers
- Subject: Re: nil pointers
- From: Uli Kusterer <email@hidden>
- Date: Wed, 12 Jul 2006 00:42:23 +0200
Bill Bumgarner wrote:
You could likely also go for ((id) -1)-- whatever the magic cast
would be-- as that should produce an address that cannot possibly
be a pointer to anything as it is the very last byte of address
space (no room for the other 3 bytes of the address).
I think you mistyped here. No room for more than the first byte of
the object. The address will always have enough memory because you've
likely already allocated an ivar or local to hold it.
Am 11.07.2006 um 20:07 schrieb glenn andreas:
How about something more "deadbeef"ish like:
#define COCOA_INVALID ((id) 0xC0C0ABAD)
That way your not likely to get confused with a stray 1 or -1 (for
example, register coloring may result in sharing a local variable
with an integer that could easily be 1 or -1, and C0C0ABAD would be
clearly an "invalid initialized" id instead of an "accidentally
uninitialized variable")
I'm not really familiar with the inner workings of Darwin's memory
allocation, but I'd guess that this value might actually be a valid
address in your address space.
Cheers,
-- M. Uli Kusterer
http://www.zathras.de
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden