diff options
| author | TSRBerry <20988865+TSRBerry@users.noreply.github.com> | 2023-06-24 02:46:04 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-06-24 02:46:04 +0200 |
| commit | 7d160e98fde05e0b9b542dc04ea72dc34994bc5b (patch) | |
| tree | 958d5f376a5a2421a7a58b21080eb454f9c744c1 /src/Ryujinx.Memory/MemoryManagementWindows.cs | |
| parent | bf96bc84a82f2c4ab771b2ab0c610f86d00b1adf (diff) | |
MemoryManagement: Change return types for Commit/Decommit to void (#5325)
* Replace return type with void for Commit/Decommit
* Small cleanup
Diffstat (limited to 'src/Ryujinx.Memory/MemoryManagementWindows.cs')
| -rw-r--r-- | src/Ryujinx.Memory/MemoryManagementWindows.cs | 16 |
1 files changed, 11 insertions, 5 deletions
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) |
