From: James J. <jam...@gm...> - 2006-01-15 23:27:45
|
Hello, I have a function in a dll which needs to return a array of structs (or a list of structs, or a list of objects/classes). After a bit of reading i managed to return a C struct and a array of int. My java program can read those without problems. But i'm now stuck with the question how to return a array of structs to my java program. I already made a working C test code: =3D=3D=3D=3D=3D=3D=3D=3D typedef struct point { int x; int y; } Point; Point *point_create(int x, int y) { Point *p =3D (Point *) malloc(sizeof(Point)); p->x =3D x; p->y =3D y; return p; } void change(Point *p[]){ =09p[0]=3Dpoint_create(0, 0); =09p[0]->x=3D10; =09p[0]->y=3D10; } int main (){ =09 Point *pts[5]; =09 change(pts); =09printf("\n%s", point_toString(pts[0]));=09 //clear memory } =3D=3D=3D=3D=3D=3D=3D=3D How should i define the "void change(Point *p[])" in the interface file? I already defined the "point_create" and "typedef struct point" in the interface file and they are working. Or is there maybe a better solution for returning x objects? Kind regards, James |