[Mono-dev] [PATCH] Managed Marshal.Copy implemantations

Kornél Pál kornelpal at gmail.com
Mon Dec 17 06:39:41 EST 2007


>From: "Paolo Molaro" <lupus at ximian.com>
>I'm not opposed to have this stuff implemented in managed code

That's good.

>(for example the original C implementation has a bug and
>in your code it's duplicated several times)

What is that bug?

>and you also managed to hide
>the assignment of a local var inside of a conditional expression.

Is that a bad practice?

>Your code also omits a check that the current code does of the rank of
>the array.

I don't see any reason for that check because as far as I know byte[,] for 
example cannot be casted to byte[]. Did I miss something?

>I would support a change that reimplemented in managed code
>copy_to_unmanaged()/copy_from_unmanaged(), maybe passing the array
>element size as an additional argument.
>To do this you just need an additional internal call that returns
>a IntPtr to the start of the elements given an Array (the JIT can
>recognize this icall and turn it into an addition of a constant).

I really like this idea and I think that System.Buffer could use the same 
icalls. I'll try to implement this.

My only problem is that I don't know how could I effectively obtain a pinned 
pointer to a managed object (currently Array) using C#. Do you have a good 
idea?

Thank you for your help.

 Kornél 




More information about the Mono-devel-list mailing list