6 messages in net.java.dev.jna.usersRe: [jna-users] Reading a native array
FromSent OnAttachments
ThinnerDec 13, 2008 5:06 am 
Timothy WallDec 13, 2008 5:11 am 
ThinnerDec 13, 2008 5:15 am 
Timothy WallDec 13, 2008 5:32 am 
ThinnerDec 13, 2008 6:17 am 
Timothy WallDec 13, 2008 9:00 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] Reading a native arrayActions...
From:Thinner (eno@gmail.com)
Date:Dec 13, 2008 5:15:32 am
List:net.java.dev.jna.users

Ok, I changed the type of data to Pointer and then called Pointer.getByteBuffer(0, length); and then tried to loop through the buffer but as soon as I call ByteBuffer.get() I get seg fault. Do I need to allocate something somewhere? :)

On Sat, Dec 13, 2008 at 2:12 PM, Timothy Wall <twal@dev.java.net>wrote:

primitive arrays within a struct are inlined. you need a pointer type.

On Dec 13, 2008, at 8:07 AM, Thinner wrote:

Hello again everyone.

I'm trying to read a native char* from my Java app but I keep getting seg fault.

struct stru{ int length; char* data; }

struct stru *return_value some_function(){ }

public class stru extends Structure{ public static class ByReference extends stru implements Structure.ByReference{}

int length; byte[] data;

public stru{ data = new byte[1]; } }

public static void main(String[] args){ myLibrary.INSTANCE }

Nor a spork, I suppose.