I have the following extract of C header from the project that I would like to map to Java using JNA:
...
typedef size_t ObjectHandle;
typedef const char *FfiStr;
typedef struct FfiList_FfiStr {
size_t count;
const FfiStr *data;
} FfiList_FfiStr;
typedef struct FfiList_FfiStr FfiStrList;
int create_schema(FfiStr schema_name,
FfiStr schema_version,
FfiStr issuer_id,
FfiStrList attr_names,
ObjectHandle *result_p);
...
I cannot find the right mapping to Java for the FfiStrList type.
Here is the mapping I have tried in Java:
public interface CredLibrary extends Library {
CredLibrary INSTANCE = (CredLibrary) Native.load("credlibrary", CredLibrary.class);
public class FfiList_FfiStr extends Structure {
public Size_t count;
public Pointer data ;
public FfiList_FfiStr(String[] attr) {
count = new Size_t(attr.length);
data = new StringArray(attr);
}
@Override
protected List getFieldOrder() {
return Arrays.asList("count", "data");
}
}
int create_link_secret(PointerByReference link_secret_p);
int generate_nonce(PointerByReference nonce_p);
int create_schema(String schema_name, String schema_version, String issuer_id,FfiList_FfiStr attr_names, IntByReference result_p);
}
The first create_link_secret and generate_nonce functions work fine, create_schema doesn't work.
And here is the test I have tried:
String schema_name= new String("test");To be more precise, in my logs I first receive the following warning :
malloc(3219533512759680) failed: returning null pointer
And then I receive an handle_alloc_error inside create_schema although I know that with the original code this function works perfectly fine.
Would it be possible to indicate what I do wrong? it seems like the malloc function is receiving the wrong argument. It seems like it is receiving something like a pointer whereas it should normally receive a much smaller value. Maybe something is wrong with my java FfiList_FfiStr structure that makes it like that.
--
You received this message because you are subscribed to the Google Groups "Java Native Access" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jna-users+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jna-users/592d0ff5-a283-45ef-b827-e4c099999009n%40googlegroups.com.
I have the following extract of C header from the project that I would like to map to Java using JNA:
typedef struct FfiList_FfiStr {
size_t count;
const FfiStr *data;
} FfiList_FfiStr;
typedef struct FfiList_FfiStr FfiStrList;
int create_schema(FfiStr schema_name,
FfiStr schema_version,
FfiStr issuer_id,
FfiStrList attr_names,
ObjectHandle *result_p);
...
I cannot find the right mapping to Java for the FfiStrList type.
Here is the mapping I have tried in Java:
public interface CredLibrary extends Library {
CredLibrary INSTANCE = (CredLibrary) Native.load("credlibrary", CredLibrary.class);
public class FfiList_FfiStr extends Structure {
public Size_t count;
public Pointer data ;
}
int create_schema(String schema_name, String schema_version, String issuer_id,FfiList_FfiStr attr_names, IntByReference result_p);
}