passing a int** to a C routine using JNA
I'm having in my java program a int[][] that 开发者_运维百科stores some data I want to compute (alter) in a C routine. But I can't figure out how to pass the "pointer to pointer to int" to the C code which declares a f(int sz, int** structure). Any idea?
Thanks, Luc.d
Since this is question is tagged JNA, Similar Example in JNA docs
// Original C declaration
void allocate_buffer(char **bufp, int* lenp);
// Equivalent JNA mapping
void allocate_buffer(PointerByReference bufp, IntByReference lenp);
// Usage
PointerByReference pref = new PointerByReference();
IntByReference iref = new IntByReference();
lib.allocate_buffer(pref, iref);
Pointer p = pref.getValue();
byte[] buffer = p.getByteArray(0, iref.getValue());
Isn't this what you are looking for ? you use PointerByReference when there is a Pointer to a Pointer.
I think this example might come in handy :)
精彩评论