diff --git a/src/bindings/mono/eina_mono/eina_common.cs b/src/bindings/mono/eina_mono/eina_common.cs index 4bd93ce25b..8bccc06ea4 100644 --- a/src/bindings/mono/eina_mono/eina_common.cs +++ b/src/bindings/mono/eina_mono/eina_common.cs @@ -110,11 +110,9 @@ public static class PrimitiveConversion public static IntPtr ManagedToPointerAlloc(T man) { - GCHandle pinnedData = GCHandle.Alloc(man, GCHandleType.Pinned); - IntPtr ptr = pinnedData.AddrOfPinnedObject(); - IntPtr nat = MemoryNative.AllocCopy(ptr, Marshal.SizeOf()); - pinnedData.Free(); - return nat; + IntPtr ptr = Marshal.AllocHGlobal(Marshal.SizeOf()); + Marshal.StructureToPtr(man, ptr, false); + return ptr; } }