Updated code to better code style.

This commit is contained in:
Maxiebyte 2014-06-09 20:17:09 +02:00
parent 4a0430d5eb
commit c73ae585eb

View File

@ -129,7 +129,9 @@ void FreeMemoryPages(void* ptr, size_t size)
#ifdef _WIN32
if (!VirtualFree(ptr, 0, MEM_RELEASE))
{
PanicAlert("FreeMemoryPages failed!\n%s", GetLastErrorMsg());
}
ptr = NULL; // Is this our responsibility?
#else
@ -155,7 +157,9 @@ void WriteProtectMemory(void* ptr, size_t size, bool allowExecute)
#ifdef _WIN32
DWORD oldValue;
if (!VirtualProtect(ptr, size, allowExecute ? PAGE_EXECUTE_READ : PAGE_READONLY, &oldValue))
{
PanicAlert("WriteProtectMemory failed!\n%s", GetLastErrorMsg());
}
#else
mprotect(ptr, size, allowExecute ? (PROT_READ | PROT_EXEC) : PROT_READ);
#endif
@ -166,7 +170,9 @@ void UnWriteProtectMemory(void* ptr, size_t size, bool allowExecute)
#ifdef _WIN32
DWORD oldValue;
if (!VirtualProtect(ptr, size, allowExecute ? PAGE_EXECUTE_READWRITE : PAGE_READWRITE, &oldValue))
{
PanicAlert("UnWriteProtectMemory failed!\n%s", GetLastErrorMsg());
}
#else
mprotect(ptr, size, allowExecute ? (PROT_READ | PROT_WRITE | PROT_EXEC) : PROT_WRITE | PROT_READ);
#endif
@ -184,11 +190,12 @@ std::string MemUsage()
// Print information about the memory usage of the process.
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)))
{
Ret = StringFromFormat("%s K", ThousandSeparate(pmc.WorkingSetSize / 1024, 7).c_str());
}
CloseHandle(hProcess);
return Ret;
#else