0

Possible Duplicate:
How to pass C structs back and forth to Java code in JNI?

I am writing a native library whose function takes a file location as an argument and returns a struct containing a pointer to an array, its array_size and no_of_clicks. A search on the internet have reveled some answers but none clear enough for me. It would be helpful if you could explain it with an example.

For instance, I have the following struct

typedef struct {
int size;
    int no_of_clicks;
float *array_location;

}return_array;

basically this struct contains the pointer to a float array location and the size of the array and an additional parameter, no_of_clicks. How do i pass this to the java side and access it there?

Community
  • 1
  • 1
Gan
  • 1,349
  • 2
  • 10
  • 27
  • 7
    Please see http://stackoverflow.com/questions/3923299/how-to-pass-c-structs-back-and-forth-to-java-code-in-jni – Andrey Ermakov Jun 20 '12 at 12:46
  • @Gan i'd like to help you, but can you explain me in detail,just edit your question with prototype of the method which you are talking about.i am not clear with what are the parameters you are passing to that and in return what you are expecting. – johnkrishna Jun 21 '12 at 04:43
  • @Andrey I already had a look at this link, but it wasn't explained in detail enough for me to grasp, so i decided to ask for better explanation. – Gan Jun 21 '12 at 12:49
  • @johnkrishna: There was a typo, which might have led to some confusion, i have edited it now. I have solved my problem of passing data through arrays using the answer provided in [link](http://stackoverflow.com/questions/1610045/how-to-return-an-array-from-jni-to-java). but I am also curious to know how to pass a structure and about the memory complications of passing a memory reference ( in this case the float array). – Gan Jun 21 '12 at 12:56

0 Answers0