I still got seg fault when calling Pointer.getByteArray(0, stru.length); It
works if I change the type of data back to byte[] and initialize the byte
array to the maximum length data will ever have (2404b). Got any ideas?
On Sat, Dec 13, 2008 at 2:32 PM, Timothy Wall <twal...@dev.java.net>wrote:
Pointer.getString(0, stru.length) if it's a string.
Pointer.getByteArray(0, stru.length) if it's raw data.
getByteBuffer() pulls out a pointer from offset zero and creates a buffer
from that, as opposed to converting the original pointer to a buffer, which
is what you were expecting.
On Dec 13, 2008, at 8:16 AM, Thinner wrote:
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.