1 message in net.java.dev.jna.usersRe: [jna-users] Nested structure arra...
FromSent OnAttachments
Timothy WallJan 22, 2008 10:25 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] Nested structure array problemActions...
From:Timothy Wall (twal@dev.java.net)
Date:Jan 22, 2008 10:25:20 am
List:net.java.dev.jna.users

On Jan 22, 2008, at 12:04 PM, Zaharescu Valentin wrote:

Thank you for the quick answer. Maybe I was not clear enough in my previous question. My problem is not reading the values from a given memory block but filling such a memory block with the given Structure in order to be passed as parameter in a call of a C function. I tried different mappings and different ways to fill the values but without succes till now.

You need a pointer to pointer to struct.

Structure.toArray() gives you as many structs contiguously as you want. Structure.getPointer() gives you pointer to struct. PointerByReference gives you pointer to pointer.

So the following should initialize things properly:

Structure[] array = new MyStructure.toArray(size); PointerByReference pref = new PointerByReference(array[0].getPointer());

Here the the C code:

typedef struct MyStructList { MyStruct **list; int64_t length; } MyStructList;