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()).