Re: [Mono-dev] PtrToStructure, FreeHGlobal, then access to the structure

2008-08-19 Thread Andy Hume
Thanks Robert. Makes sense in hindsight, that the managed struct is a copy of the native source (the native struct being copied onto the managed struct's memory IIUC)! Thus one bug report only (#417256 in Win32 Printing). Andy Robert Jordan wrote: > > Andy Hume wrote: >> In the class librar

Re: [Mono-dev] PtrToStructure, FreeHGlobal, then access to the structure

2008-08-12 Thread Robert Jordan
Andy Hume wrote: > In the class library I see a few pieces of code like the following. Am I > correct in thinking that code like this is bad? Only if the .Name ptr is pointing to a memory block inside the struct's area. So it depends on the specification of the struct being marshaled. >info

[Mono-dev] PtrToStructure, FreeHGlobal, then access to the structure

2008-08-12 Thread Andy Hume
In the class library I see a few pieces of code like the following. Am I correct in thinking that code like this is bad? info = Marshal.PtrToStructure (ptr, ...); Marshal.FreeHGlobal (ptr); // now we access the structure int id = info.Id; string name = Marshal.PtrToStringUni (info