Browse Source

Refactor MemoryBuffer -> MemoryAllocator

ghorsington 3 years ago
parent
commit
7491d608ff

+ 6 - 6
BepInEx.IL2CPP/Hook/Buffer/MemoryBuffer.cs

@@ -8,7 +8,7 @@ namespace BepInEx.IL2CPP
 	/// 
 	///     Based on https://github.com/kubo/funchook
 	/// </summary>
-	internal abstract class MemoryBuffer
+	internal abstract class MemoryAllocator
 	{
 		/// <summary>
 		///     Common page size on Unix and Windows (4k).
@@ -20,8 +20,8 @@ namespace BepInEx.IL2CPP
 		/// </summary>
 		protected const int ALLOCATION_UNIT = 0x100000;
 
-		private static MemoryBuffer instance;
-		public static MemoryBuffer Instance => instance ??= Init();
+		private static MemoryAllocator instance;
+		public static MemoryAllocator Instance => instance ??= Init();
 
 		public abstract IntPtr Allocate(IntPtr func);
 		public abstract void Free(IntPtr buffer);
@@ -38,12 +38,12 @@ namespace BepInEx.IL2CPP
 			return (num + unit - 1) & ~ (unit - 1);
 		}
 
-		private static MemoryBuffer Init()
+		private static MemoryAllocator Init()
 		{
 			if (PlatformHelper.Is(Platform.Windows))
-				return new WindowsMemoryBuffer();
+				return new WindowsMemoryAllocator();
 			if (PlatformHelper.Is(Platform.Unix))
-				return new UnixMemoryBuffer();
+				return new UnixMemoryAllocator();
 			throw new NotImplementedException();
 		}
 	}

+ 1 - 1
BepInEx.IL2CPP/Hook/Buffer/UnixMemoryBuffer.cs

@@ -5,7 +5,7 @@ namespace BepInEx.IL2CPP
 	/// <summary>
 	///     Based on https://github.com/kubo/funchook
 	/// </summary>
-	internal class UnixMemoryBuffer : MemoryBuffer
+	internal class UnixMemoryAllocator : MemoryAllocator
 	{
 		public override IntPtr Allocate(IntPtr func)
 		{

+ 1 - 1
BepInEx.IL2CPP/Hook/Buffer/WindowsMemoryBuffer.cs

@@ -8,7 +8,7 @@ namespace BepInEx.IL2CPP
 	/// <summary>
 	///     Based on https://github.com/kubo/funchook
 	/// </summary>
-	internal class WindowsMemoryBuffer : MemoryBuffer
+	internal class WindowsMemoryAllocator : MemoryAllocator
 	{
 		private readonly LinkedList<IntPtr> allocatedChunks = new LinkedList<IntPtr>();