I have a c++ function defined as
extern "C" Point* myFunc(int size) {
Point *p = new Point[size];
return p;
}
where point is just a struct defined as
extern "C" typedef struct _point {
int x;
int y;
} Point;
and inside my c# code I have
[DllImport("MyLibrary")]
static extern Point[] myFunc(int size);
and I use it as
Point[] newPoints = myFunc(3);
Debug.Log(newPoints.Length);
But the output is
33
The function is just an example, but the lenght of the array returned shouldn't be known before the function call. What is the correct way of returning an array to c# in order to use it, know its size and access it without incurring in any IndexOutOfRangeException?