Re: correct way to find if 32bits is an object pointer?
Re: correct way to find if 32bits is an object pointer?
- Subject: Re: correct way to find if 32bits is an object pointer?
- From: John Hörnkvist <email@hidden>
- Date: Tue, 19 Feb 2002 15:40:08 +0100
On Tuesday, February 19, 2002, at 03:27 PM, Lance Bland wrote:
On Tuesday, February 19, 2002, at 09:05 AM, Ondra Cada wrote:
AFAIK, this is quite difficult. If you do need that, you have to first
check
whether the address itself is valid (see vm_region()), and if so,
check its
contents ("manually", ie. check whether the isa value is valid itself,
whether is has proper contents like the class name, etc.).
That is what I want, and what I was planning to do. It sounds pretty
complete to me. I don't see any pitfalls besides the unlikely situation
where a string matching a class name would just happen to be at the
right location in memory. What is the chance of that? :-) I just want
to make sure not to raise an exception when I do the checking.
Wouldn't it be better to use a list of classes, using objc_getClassList?
Then you only need to check that the object's isa points to one of the
known classes.
"if ptr is a valid pointer and ptr->isa is in the set of classes, then
it is an object."
Regards,
John Hornkvist
--
ToastedMarshmallow, the perfect Cocoa companion
http://www.toastedmarshmallow.com
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.