Hello,
till now I could manage well with mapping from Native C.
However I reached a point where the memory is not filled correctly, it's
always null for an internal list.
Here the the C code:
typedef struct MyStructList
{
MyStruct **list;
int64_t length;
} MyStructList;
where MyStruct is defined as follows:
typedef struct MyStruct
{
int8_t *name;
int64_t index;
} MyStruct;
and
DLLAPI void testMyStruct(const MyStructList *structList);
I have mapped MyStruct to JNA as follows:
public class MyStruct extends Structure implements Serializable {
public static class ByValue extends MyStruct implements Structure.ByValue
{ }//also used ByReference...
public String name;
public long index;
public MyStruct() {
}
public MyStruct(String name, long index) {
this.name = name;
this.index = index;
}
}
Somehow I tried several possibilities to map MyStructList, here one guess:
public class MyStructList extends Structure implements Serializable {
public static class ByReference extends MyStructList implements
Structure.ByReference { }
public Pointer list;
public long length;
...
public MyStructList(MyStruct[] myStruct) {
this.length += 1;
MyStruct tmp = new MyStruct();
MyStruct[] t = (MyStruct[]) tmp.toArray((int)this.length);
for(int i=0; i<this.length; i++) {
MyStruct tb = tmp;
tb.name = myStruct[i].name;
tb.index = myStruct[i].index;
t[i] = tb;
}
this.list = tmp.getPointer();
allocateMemory();
}
}
I tested with one element. In the Java debugger everything seems to be
correct, however on the C side, the first entry in the list is NULL.
So how do I have to map and to handle this correctly?
Thanks in advance,
Dirk