mirror of
https://github.com/citra-emu/citra.git
synced 2024-11-22 19:20:04 +00:00
Updated code to better code style.
This commit is contained in:
parent
4a0430d5eb
commit
c73ae585eb
@ -129,7 +129,9 @@ void FreeMemoryPages(void* ptr, size_t size)
|
|||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
|
|
||||||
if (!VirtualFree(ptr, 0, MEM_RELEASE))
|
if (!VirtualFree(ptr, 0, MEM_RELEASE))
|
||||||
|
{
|
||||||
PanicAlert("FreeMemoryPages failed!\n%s", GetLastErrorMsg());
|
PanicAlert("FreeMemoryPages failed!\n%s", GetLastErrorMsg());
|
||||||
|
}
|
||||||
ptr = NULL; // Is this our responsibility?
|
ptr = NULL; // Is this our responsibility?
|
||||||
|
|
||||||
#else
|
#else
|
||||||
@ -155,7 +157,9 @@ void WriteProtectMemory(void* ptr, size_t size, bool allowExecute)
|
|||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
DWORD oldValue;
|
DWORD oldValue;
|
||||||
if (!VirtualProtect(ptr, size, allowExecute ? PAGE_EXECUTE_READ : PAGE_READONLY, &oldValue))
|
if (!VirtualProtect(ptr, size, allowExecute ? PAGE_EXECUTE_READ : PAGE_READONLY, &oldValue))
|
||||||
|
{
|
||||||
PanicAlert("WriteProtectMemory failed!\n%s", GetLastErrorMsg());
|
PanicAlert("WriteProtectMemory failed!\n%s", GetLastErrorMsg());
|
||||||
|
}
|
||||||
#else
|
#else
|
||||||
mprotect(ptr, size, allowExecute ? (PROT_READ | PROT_EXEC) : PROT_READ);
|
mprotect(ptr, size, allowExecute ? (PROT_READ | PROT_EXEC) : PROT_READ);
|
||||||
#endif
|
#endif
|
||||||
@ -166,7 +170,9 @@ void UnWriteProtectMemory(void* ptr, size_t size, bool allowExecute)
|
|||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
DWORD oldValue;
|
DWORD oldValue;
|
||||||
if (!VirtualProtect(ptr, size, allowExecute ? PAGE_EXECUTE_READWRITE : PAGE_READWRITE, &oldValue))
|
if (!VirtualProtect(ptr, size, allowExecute ? PAGE_EXECUTE_READWRITE : PAGE_READWRITE, &oldValue))
|
||||||
|
{
|
||||||
PanicAlert("UnWriteProtectMemory failed!\n%s", GetLastErrorMsg());
|
PanicAlert("UnWriteProtectMemory failed!\n%s", GetLastErrorMsg());
|
||||||
|
}
|
||||||
#else
|
#else
|
||||||
mprotect(ptr, size, allowExecute ? (PROT_READ | PROT_WRITE | PROT_EXEC) : PROT_WRITE | PROT_READ);
|
mprotect(ptr, size, allowExecute ? (PROT_READ | PROT_WRITE | PROT_EXEC) : PROT_WRITE | PROT_READ);
|
||||||
#endif
|
#endif
|
||||||
@ -184,11 +190,12 @@ std::string MemUsage()
|
|||||||
// Print information about the memory usage of the process.
|
// Print information about the memory usage of the process.
|
||||||
|
|
||||||
hProcess = OpenProcess(PROCESS_QUERY_INFORMATION | PROCESS_VM_READ, FALSE, processID);
|
hProcess = OpenProcess(PROCESS_QUERY_INFORMATION | PROCESS_VM_READ, FALSE, processID);
|
||||||
if (NULL == hProcess) return "MemUsage Error";
|
if (NULL == hProcess) { return "MemUsage Error";}
|
||||||
|
|
||||||
if (GetProcessMemoryInfo(hProcess, &pmc, sizeof(pmc)))
|
if (GetProcessMemoryInfo(hProcess, &pmc, sizeof(pmc)))
|
||||||
|
{
|
||||||
Ret = StringFromFormat("%s K", ThousandSeparate(pmc.WorkingSetSize / 1024, 7).c_str());
|
Ret = StringFromFormat("%s K", ThousandSeparate(pmc.WorkingSetSize / 1024, 7).c_str());
|
||||||
|
}
|
||||||
CloseHandle(hProcess);
|
CloseHandle(hProcess);
|
||||||
return Ret;
|
return Ret;
|
||||||
#else
|
#else
|
||||||
|
Loading…
Reference in New Issue
Block a user