Dereferencing PtrData in Ruby/DL

C

Carl Youngblood

Hello. I have allocated a pointer using DL.malloc:

window = DL.malloc(DL.sizeof('P'))

At times in my code I have to pass a pointer this pointer, and at
other times I have to pass in the value of the pointer itself. Does
anybody know how to dereference PtrData?

Thanks,
Carl Youngblood
 
J

Jamis Buck

Carl said:
Hello. I have allocated a pointer using DL.malloc:

window = DL.malloc(DL.sizeof('P'))

At times in my code I have to pass a pointer this pointer, and at
other times I have to pass in the value of the pointer itself. Does
anybody know how to dereference PtrData?

Thanks,
Carl Youngblood

Carl,

I believe that if you have a variable 'x' that is a DL::ptrData
instance, you can do:

y = x.ref #-> get pointer to the pointer x
z = y.ptr #-> obtain the value that y points to, as a PtrData
assert x == z

I only tried this in IRB, but it appears to work as I described it.

- Jamis
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,160
Messages
2,570,889
Members
47,422
Latest member
LatashiaZc

Latest Threads

Top