• 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: nil pointers
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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
  • Follow-Ups:
    • Re: nil pointers
      • From: Bill Bumgarner <email@hidden>
References: 
 >nil pointers (From: "Adam Johnson" <email@hidden>)
 >Re: nil pointers (From: Uli Kusterer <email@hidden>)
 >Re: nil pointers (From: Rob Ross <email@hidden>)
 >Re: nil pointers (From: Andreas Mayer <email@hidden>)
 >Re: nil pointers (From: Bill Bumgarner <email@hidden>)
 >Re: nil pointers (From: Uli Kusterer <email@hidden>)
 >Re: nil pointers (From: glenn andreas <email@hidden>)

  • Prev by Date: Re: Re: Selector Not Recognized
  • Next by Date: Getting added object with KVO
  • Previous by thread: Re: nil pointers
  • Next by thread: Re: nil pointers
  • Index(es):
    • Date
    • Thread