From 7d160e98fde05e0b9b542dc04ea72dc34994bc5b Mon Sep 17 00:00:00 2001 From: TSRBerry <20988865+TSRBerry@users.noreply.github.com> Date: Sat, 24 Jun 2023 02:46:04 +0200 Subject: MemoryManagement: Change return types for Commit/Decommit to void (#5325) * Replace return type with void for Commit/Decommit * Small cleanup --- src/Ryujinx.Memory/MemoryManagementWindows.cs | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'src/Ryujinx.Memory/MemoryManagementWindows.cs') diff --git a/src/Ryujinx.Memory/MemoryManagementWindows.cs b/src/Ryujinx.Memory/MemoryManagementWindows.cs index cbf3ecba..d7d78bd8 100644 --- a/src/Ryujinx.Memory/MemoryManagementWindows.cs +++ b/src/Ryujinx.Memory/MemoryManagementWindows.cs @@ -10,7 +10,7 @@ namespace Ryujinx.Memory { public const int PageSize = 0x1000; - private static readonly PlaceholderManager _placeholders = new PlaceholderManager(); + private static readonly PlaceholderManager _placeholders = new(); public static IntPtr Allocate(IntPtr size) { @@ -55,14 +55,20 @@ namespace Ryujinx.Memory return ptr; } - public static bool Commit(IntPtr location, IntPtr size) + public static void Commit(IntPtr location, IntPtr size) { - return WindowsApi.VirtualAlloc(location, size, AllocationType.Commit, MemoryProtection.ReadWrite) != IntPtr.Zero; + if (WindowsApi.VirtualAlloc(location, size, AllocationType.Commit, MemoryProtection.ReadWrite) == IntPtr.Zero) + { + throw new SystemException(Marshal.GetLastPInvokeErrorMessage()); + } } - public static bool Decommit(IntPtr location, IntPtr size) + public static void Decommit(IntPtr location, IntPtr size) { - return WindowsApi.VirtualFree(location, size, AllocationType.Decommit); + if (!WindowsApi.VirtualFree(location, size, AllocationType.Decommit)) + { + throw new SystemException(Marshal.GetLastPInvokeErrorMessage()); + } } public static void MapView(IntPtr sharedMemory, ulong srcOffset, IntPtr location, IntPtr size, MemoryBlock owner) -- cgit v1.2.3