[Mono-list] Marshalling byte[]

Dmitry Kostenko bis0n@mail.ru
Thu, 28 Oct 2004 06:07:19 +0300


On Wednesday 27 October 2004 19:53, Neale.Ferguson@SoftwareAG-USA.com wrote:


> int scumbag(int *X, char *fb, char *rb ...)

How does your C function determine the size of arrays? 

> (the int values were the for the marshalling code that uses the
> sizeparamindex value to determine the size of the byte arrays)

It looks like you marshal from Mono to C code (the array pointers are 
readonly). In this case extra arguments are not necessary, the CLR will 
determine the size of array at run-time using Array.Length property.

So, the C# prototype most probably would be:
extern static int scumbag(ref int X, byte[] fb, byte[] rb, ...);

And to use it you can:
{
   byte[] rb = new byte[1024]; //here is where you set the size.
   byte[] fb = new byte[512];
   int x = 0;
   scumbag(ref x, fb, rb,...);
}

> _______________________________________________
> Mono-list maillist  -  Mono-list@lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/mono-list

-- 
Dmitry Kostenko
.NET Developer
Registered Linux User #286813