Mapping a pointer to an array of structures in JNA

I would like to get an array from a pointer like this:

PointerByReference buf=new PointerByReference(); IntByReference len=new IntByReference(); myLib.getPoints(buf,len); Pointer p=buf.getValue(); JNAPoint jnaPoint=new JNAPoint(p); JNAPoint[] points=(JNAPoint[])jnaPoint.toArray(len.getValue()); 

The prototype of the function is: void __declspec (dllexport) getPoints (dot ** tab, int * len);

Structure: typedef struct _point {double x; double y; } point;

But, when I want to read the "points" of the array, the values ​​are incorrect.

Is there a mistake?

thanks

+4
source share

Source: https://habr.com/ru/post/1436228/


All Articles