public static void StructureToPtr(object structure, IntPtr ptr, bool fDeleteOld) { AllocationInfo info; if (allocated.TryGetValue(ptr, out info)) { Debug.Assert(fDeleteOld == (info.dotNetType != null)); } else { info = new AllocationInfo(AllocationType.External, 0); allocated.Add(ptr, info); } // // ISSUE-What is the postcondition of StructureToPtr if it throws // when fDeleteOld is true? // Marshal.StructureToPtr(structure, ptr, fDeleteOld); info.dotNetType = structure.GetType(); }