[Mono-list] P/Invoke question
Wed, 16 Mar 2005 16:37:12 -0800 (PST)
--- Kelly Leahy <email@example.com> wrote:
> However, I don't think this is right either. I
> perhaps your C declaration is either wrong, or the
> caller has to preallocate the array of CvPoint2D32f
> elements before calling this function.
Looking at the documentation for this function at:
I was correct.
The caller is responsible for preallocating the array
of CvPoint2D32f records.
For the purposes of building a nice C# wrapper, you
could either take a "length" argument or use the array
length to determine how many points to handle. I
think taking a length argument is cleaner, (and allows
the caller to use a subset of the array), but either
solution is possible.
For instance, you could declare the P/Invoke function
to take an array of CvPoint2D32f elements, then
construct this array in the code that calls this
function (the wrapper) with the appropriate size.
Perhaps, if you know CvPoint2D32f to be of type float,
you could even pass this array to the Marshal.Copy