[Mono-list] managed question

Lloyd Dupont lloyd@galador.net
Sat, 24 Nov 2001 00:36:46 +0100


i wonder how the runtime could change all reference to a variable, did 
he really do this ?
i am astonished that you need pinning array type before getting the 
underlying pointer.

if i have an instance array variable, and pass it to a C function as an 
(type *) (type pointer) which memorise it in inner C struct to fill it 
later through other C call.
does i really risk to write in unaffected memory ?
wht could id do against this ?

naive example of potentially erroneous code:
---------------------------
class MyClass
{
	static int[] myBuf = new int[25];

	// set the native buf
	[DllImport("myDll")]
	static extern void setBuffer(int[] buf, int len);

	// set the first value of buf
	[DllImport("myDll")]
	static extern void fill0(int value);

	public static void Main()
	{
		setBuffer(myBuf, 25);
		fill0(33);

		// should output 33, is it ok ? is it safe ?
		System.WriteLine(myBuf[0]);
	}
}