MemoryManagement: Change return types for Commit/Decommit to void (#5325)

* Replace return type with void for Commit/Decommit

* Small cleanup
This commit is contained in:
TSRBerry 2023-06-24 02:46:04 +02:00 committed by GitHub
parent bf96bc84a8
commit 7d160e98fd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 32 additions and 33 deletions

View file

@ -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)