public IntPtr ManagedToNativeAlloc(T man) { GCHandle pinnedData = GCHandle.Alloc(man, GCHandleType.Pinned); IntPtr ptr = pinnedData.AddrOfPinnedObject(); IntPtr nat = MemoryNative.AllocCopy(ptr, Marshal.SizeOf <T>()); pinnedData.Free(); return(nat); }
public IntPtr ManagedToNativeAllocInlistNode(T man) { var node = new InlistNode <IntPtr>(); node.Val = ManagedToNativeAlloc(man); GCHandle pinnedData = GCHandle.Alloc(node, GCHandleType.Pinned); IntPtr ptr = pinnedData.AddrOfPinnedObject(); IntPtr nat = MemoryNative.AllocCopy(ptr, Marshal.SizeOf <InlistNode <IntPtr> >()); pinnedData.Free(); return(nat); }