8 messages in net.java.dev.jna.usersRe: [jna-users] getting at a structur...
FromSent OnAttachments
Paul LoyJan 23, 2008 10:34 am 
Timothy WallJan 23, 2008 11:04 am 
Paul LoyJan 24, 2008 5:29 am 
Paul LoyJan 24, 2008 5:30 am 
Timothy WallJan 24, 2008 5:38 am 
Paul LoyJan 25, 2008 5:24 am 
Timothy WallJan 25, 2008 5:58 am 
Paul LoyJan 25, 2008 6:50 am 
Actions with this message:
Paste this link in email or IM:
Paste this link in email or IM:
Atom feed for this thread
Paste this URL into your reader:
Subject:Re: [jna-users] getting at a structure with unknown structure sizeActions...
From:Timothy Wall (twal@dev.java.net)
Date:Jan 24, 2008 5:38:04 am
List:net.java.dev.jna.users

On Jan 24, 2008, at 8:30 AM, Paul Loy wrote:

Thanks Tim, I was using PointerByReference, but I now know the problem. As the SampleDescriptionHandle can be a variety of sizes it needs to be a "reallocatable block". Apple's docs for NewHandle specifically says:

"Do not try to manufacture your own handles without this function [NewHandle] by simply assigning the address of a variable of type Handle. The resulting 'fake handle' would not reference a relocatable block and would cause a system crash."

Now, while it doesn't always cause a system crash (in fact very rarely does it for me), it is not able to change this memory (due to it not being relocatable) and so I get garbage results. So I think I'm going to workaround, but just thought I'd let you know in case you can think of a way to handle (no pun intended) this in JNA.

So are they asking that instead of &ptr, they want you to pass the result of NewHandle?

If so, just call NewHandle (which presumably returns a Pointer, or you can define "Handle" which extends PointerType), and use the result as your argument. You can get the value with Pointer.getPointer(0) (which is the same as PointerByReference.getValue()).