On Jul 14, 2015, at 9:44 AM, Jens Alfke <j...@mooseyard.com> wrote:
>> On Jul 14, 2015, at 9:13 AM, Raglan T. Tiger <r...@crusaderrabbit.net> 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 / w...@omnigroup.com



_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to