summaryrefslogtreecommitdiff
path: root/Assembly_Firstpass/Steamworks/MMKVPMarshaller.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Assembly_Firstpass/Steamworks/MMKVPMarshaller.cs')
-rw-r--r--Assembly_Firstpass/Steamworks/MMKVPMarshaller.cs43
1 files changed, 43 insertions, 0 deletions
diff --git a/Assembly_Firstpass/Steamworks/MMKVPMarshaller.cs b/Assembly_Firstpass/Steamworks/MMKVPMarshaller.cs
new file mode 100644
index 0000000..7e73196
--- /dev/null
+++ b/Assembly_Firstpass/Steamworks/MMKVPMarshaller.cs
@@ -0,0 +1,43 @@
+using System;
+using System.Runtime.InteropServices;
+
+namespace Steamworks;
+
+public class MMKVPMarshaller
+{
+ private IntPtr m_pNativeArray;
+
+ private IntPtr m_pArrayEntries;
+
+ public MMKVPMarshaller(MatchMakingKeyValuePair_t[] filters)
+ {
+ if (filters != null)
+ {
+ int num = Marshal.SizeOf(typeof(MatchMakingKeyValuePair_t));
+ m_pNativeArray = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(IntPtr)) * filters.Length);
+ m_pArrayEntries = Marshal.AllocHGlobal(num * filters.Length);
+ for (int i = 0; i < filters.Length; i++)
+ {
+ Marshal.StructureToPtr(filters[i], new IntPtr(m_pArrayEntries.ToInt64() + i * num), fDeleteOld: false);
+ }
+ Marshal.WriteIntPtr(m_pNativeArray, m_pArrayEntries);
+ }
+ }
+
+ ~MMKVPMarshaller()
+ {
+ if (m_pArrayEntries != IntPtr.Zero)
+ {
+ Marshal.FreeHGlobal(m_pArrayEntries);
+ }
+ if (m_pNativeArray != IntPtr.Zero)
+ {
+ Marshal.FreeHGlobal(m_pNativeArray);
+ }
+ }
+
+ public static implicit operator IntPtr(MMKVPMarshaller that)
+ {
+ return that.m_pNativeArray;
+ }
+}