Checking for valid Ruby objects?

If I have a void pointer in C extension code, is there any way to tell
if it is a valid Ruby object (versus a pointer to some other data),
similar to what’s done in the (private) is_pointer_to_heap() function?

The only problem there is that, if the pointer isn’t to a valid
ruby object you run the risk of falling off the end of the world, or
misreading other data and thinking it’s an object. “A lack of
segfaulting is not proof of correctness” and all.

···

At 3:32 AM +0900 4/3/03, Lyle Johnson wrote:

If I have a void pointer in C extension code, is there any way to
tell if it is a valid Ruby object (versus a pointer to some other
data), similar to what’s done in the (private) is_pointer_to_heap()
function?


Dan

--------------------------------------“it’s like this”-------------------
Dan Sugalski even samurai
dan@sidhe.org have teddy bears and even
teddy bears get drunk

I think it should be possible to use id2ref; if it raises an exception,
then you don’t have a valid object.

I’m curious: why do you need to do this anyway?

Paul

···

On Thu, Apr 03, 2003 at 03:32:24AM +0900, Lyle Johnson wrote:

If I have a void pointer in C extension code, is there any way to tell
if it is a valid Ruby object (versus a pointer to some other data),
similar to what’s done in the (private) is_pointer_to_heap() function?