Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个字节数组,我想使用 JNA 将它传递给 C 函数。但是我只找到了使用新内存分配指针并使用写入函数复制数组数据的示例,但对我来说是不可接受的,因为我有大块数据。
是否有可能将我的 Java 数组直接传递给 c 库?
我想做这样的事情:
MyLib lib = Native.loadLibrary("test"); Pointer p = myByteArray; //I want to make it possible lib.someFunction(p);
将原始数组或 a 传递Pointer到内存是等效的操作,即您可以像这样映射:
Pointer
public interface MyLibrary extends Library { void someFunction(byte[] input); void someFunction(Pointer input); }