4 messages in net.java.dev.jna.usersRe: [jna-users] How to create a point...
FromSent OnAttachments
Christine ZimmerJan 13, 2009 2:45 am 
Nikolas LotzJan 13, 2009 5:58 am 
Christine ZimmerJan 14, 2009 11:15 pm 
Nikolas LotzJan 15, 2009 2:41 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] How to create a pointer from byte[]?Actions...
From:Christine Zimmer (chri@gmx.de)
Date:Jan 14, 2009 11:15:33 pm
List:net.java.dev.jna.users

Thanks for your help. But now I have a new problem: after calling the native function my application
terminates itself, no error message, no exception and no vm crash. The return
value of the function is a pointer (void*).

-----Ursprüngliche Nachricht----- Von: "Nikolas Lotz" <nlo@nde.ag> Gesendet: 13.01.09 15:51:19 An: use@jna.dev.java.net Betreff: Re: [jna-users] How to create a pointer from byte[]?

How can I create a Pointer from a byte array ?

try to create a new chunk of memory, fill it with your XML-data and don't forget the terminating zero-byte:

--- snip ------------------------------------------- byte[] xmlData = ...; Memory xmlBuffer = new Memory(xmlData.length + 1); xmlBuffer.write(0, xmlData, 0, xmlData.length); xmlBuffer.setByte(xmlData.length, 0); --- snap -------------------------------------------

now you can pass 'xmlBuffer' as a pointer ...

One of the parameteres of the Pointer.write(...) method is the offset ('offset - byte offset from pointer into which data is copied'). What is this offset? I don't understand the description in the javadoc.

this would be the 'destination offset' ...

Vorsitzende des Aufsichtsrates: Angelika Mozdzen Sitz und Registergericht: Hamburg, HRB 90934 Vorstand: Jens-U. Mozdzen USt-IdNr. DE 814 013 983