Browse Source

Make native address structure blittable

Stas Denisov 6 years ago
parent
commit
fe77735687
1 changed files with 3 additions and 4 deletions
  1. 3 4
      Source/Managed/ENet.cs

+ 3 - 4
Source/Managed/ENet.cs

@@ -61,10 +61,9 @@ namespace ENet {
 		Zombie = 9
 		Zombie = 9
 	}
 	}
 
 
-	[StructLayout(LayoutKind.Sequential)]
+	[StructLayout(LayoutKind.Explicit, Size = 18)]
 	internal struct ENetAddress {
 	internal struct ENetAddress {
-		[MarshalAs(UnmanagedType.ByValArray, SizeConst = 16)]
-		public byte[] ip;
+		[FieldOffset(16)]
 		public ushort port;
 		public ushort port;
 	}
 	}
 
 
@@ -1083,4 +1082,4 @@ namespace ENet {
 		[DllImport(nativeLibrary, CallingConvention = CallingConvention.Cdecl)]
 		[DllImport(nativeLibrary, CallingConvention = CallingConvention.Cdecl)]
 		internal static extern void enet_peer_reset(IntPtr peer);
 		internal static extern void enet_peer_reset(IntPtr peer);
 	}
 	}
-}
+}