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

Re: AfxIsValidAddress


  • Subject: Re: AfxIsValidAddress
  • From: Wim Lewis <email@hidden>
  • Date: Tue, 14 Jul 2015 10:09:30 -0700

On Jul 14, 2015, at 9:44 AM, Jens Alfke <email@hidden> wrote:
>> On Jul 14, 2015, at 9:13 AM, Raglan T. Tiger <email@hidden> wrote:
>>
>> Is there a Cocoa or OS X equivalent to the Windows function AfxIsValidAddress ?
>
> I don’t know, I’m not a Windows programmer. It would help if you told us what that function does.


It checks whether a given address range is mapped (or equivalent terminology on Windows). Windows has another function that programmers like to use, IsBadReadPtr(), that does something similar.

It's possible to get this information by making some Mach API calls, but unless you're doing something pretty exotic, there isn't a good reason to do it. It's better to construct your program such that you know the memory region is valid; if it isn't valid, you know your program state is corrupt, and the right thing to do in that case is crash and send a crashdump to the developer so that it can be fixed. If you don't know (with enough certainty to omit a call to IsValidAddress) whether a pointer is readable, you certainly don't know whether the data there is what you expect to be there. Memory regions get reused a lot.



Wim Lewis / email@hidden



_______________________________________________

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


  • Follow-Ups:
    • Re: AfxIsValidAddress
      • From: Kyle Sluder <email@hidden>
    • Re: AfxIsValidAddress
      • From: Scott Ribe <email@hidden>
    • Re: AfxIsValidAddress
      • From: Jens Alfke <email@hidden>
References: 
 >AfxIsValidAddress (From: "Raglan T. Tiger" <email@hidden>)
 >Re: AfxIsValidAddress (From: Jens Alfke <email@hidden>)

  • Prev by Date: Re: AfxIsValidAddress
  • Next by Date: Re: AfxIsValidAddress
  • Previous by thread: Re: AfxIsValidAddress
  • Next by thread: Re: AfxIsValidAddress
  • Index(es):
    • Date
    • Thread