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
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
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