From: Carl Youngblood Date: 2004-10-29T06:04:27+09:00 Subject: Re: Dereferencing PtrData in Ruby/DL Thanks Jamis. Now I have another problem. How do I get a pointer to a pointer? Let's say I've just allocated a pointer with: mypointer = DL.malloc(DL.sizeof('P')) How do I get a pointer to that pointer? mypointer.to_p doesn't seem to work. Anybody know? Thanks, Carl On Fri, 29 Oct 2004 03:51:07 +0900, Jamis Buck wrote: > Carl Youngblood wrote: > > > > 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.