I have an array of bytes and I want to pass it to C function using JNA. However I only found examples which allocated a pointer using new Memory and used write function to copy array data but for me is not acceptable because I have big block of data.
Is there a possibility just to pass my Java array directly to c library ?
I want to do something like this :
MyLib lib = Native.loadLibrary("test");
Pointer p = myByteArray; //I want to make it possible
lib.someFunction(p);
Passing a primitive array or a Pointer
to memory are equivalent operations, ie you can map like this:
public interface MyLibrary extends Library {
void someFunction(byte[] input);
void someFunction(Pointer input);
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.