Accessing Struct variables from JNI using SWIG

  • Thread starter Bharath Raghunathan
  • Start date
B

Bharath Raghunathan

Hello,

I have a library with the following structure:


typedef struct val_variable_string {
int offset;
int size;
char first_byte;
} val_t;

There is a function that operates on the above structure as shown below


int fun1(val_t *v)
{

int i;
char *ptr= &v->first_byte;

for (i=0; i< v->size; i++)
printf ("%c", ptr);

printf ("\n");
}

Since this is a c variable structure it is allocated in the following
way and passed onto the above function as below:

mv1 = (struct val_variable_string *) malloc(sizeof(struct
val_variable_string) + 20 );

mv1->offset = 0 ;

mv1->size = strlen(TEST_STRING);

strncpy ( &mv1->first_byte, TEST_STRING, mv1->size);


fun1(mv1);


Now Can the JNI code be generated to achieve a similar functionality
using SWIG? Is there any alternate way to achieve the above
functionality from JAVA layer.

Any help is appreciated.

Thanks in Advance


--Bharath
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,764
Messages
2,569,567
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top