3 messages in net.java.dev.jna.usersRe: [jna-users] Nested structure arra...
FromSent OnAttachments
Zaharescu ValentinJan 21, 2008 4:23 am 
Timothy WallJan 21, 2008 8:16 am 
Zaharescu ValentinJan 22, 2008 9:04 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:Zaharescu Valentin (zva@yahoo.com)
Date:Jan 22, 2008 9:04:06 am
List:net.java.dev.jna.users

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.

Thanks again, Valentin

Date: Mon, 21 Jan 2008 11:16:47 -0500 From: Timothy Wall <twal@dev.java.net> Content-type: text/plain; charset=US-ASCII; delsp=yes; format=flowed Subject: [jna-users] Nested structure array problem

On Jan 21, 2008, at 7:24 AM, Zaharescu Valentin wrote:

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;

Assuming your list is an array of struct contiguous in memory:

class MyStructList extends Structure { Pointer list; long length; MyStruct[] getList() { return new MyStruct(list.getPointer(0)).toArray((int)length); } }

class MyStruct extends Structure { public String name; public long index; public MyStruct() { } public MyStruct(Pointer p) { useMemory(p); } }

If your list is an array of pointers to struct contiguous in memory, then you would use Structure.ByReference[].

Heute schon einen Blick in die Zukunft von E-Mails wagen?
www.yahoo.de/mail