[Project64] get Recompiler Memory.cpp to use standard types
This commit is contained in:
parent
d06eae9457
commit
dda79ce345
|
@ -11,8 +11,8 @@
|
|||
#include "stdafx.h"
|
||||
|
||||
CRecompMemory::CRecompMemory() :
|
||||
m_RecompCode(NULL),
|
||||
m_RecompSize(0)
|
||||
m_RecompCode(NULL),
|
||||
m_RecompSize(0)
|
||||
{
|
||||
m_RecompPos = NULL;
|
||||
}
|
||||
|
@ -21,7 +21,7 @@ CRecompMemory::~CRecompMemory()
|
|||
{
|
||||
if (m_RecompCode)
|
||||
{
|
||||
VirtualFree( m_RecompCode, 0 , MEM_RELEASE);
|
||||
VirtualFree(m_RecompCode, 0, MEM_RELEASE);
|
||||
m_RecompCode = NULL;
|
||||
}
|
||||
m_RecompPos = NULL;
|
||||
|
@ -29,25 +29,25 @@ CRecompMemory::~CRecompMemory()
|
|||
|
||||
bool CRecompMemory::AllocateMemory()
|
||||
{
|
||||
BYTE * RecompCodeBase = (BYTE *)VirtualAlloc( NULL, MaxCompileBufferSize + 4, MEM_RESERVE|MEM_TOP_DOWN, PAGE_EXECUTE_READWRITE);
|
||||
BYTE * RecompCodeBase = (BYTE *)VirtualAlloc(NULL, MaxCompileBufferSize + 4, MEM_RESERVE | MEM_TOP_DOWN, PAGE_EXECUTE_READWRITE);
|
||||
if (RecompCodeBase == NULL)
|
||||
{
|
||||
WriteTrace(TraceError,__FUNCTION__ ": failed to allocate RecompCodeBase");
|
||||
WriteTrace(TraceError, __FUNCTION__ ": failed to allocate RecompCodeBase");
|
||||
g_Notify->DisplayError(MSG_MEM_ALLOC_ERROR);
|
||||
return false;
|
||||
}
|
||||
|
||||
m_RecompCode = (BYTE *)VirtualAlloc( RecompCodeBase, InitialCompileBufferSize, MEM_COMMIT, PAGE_EXECUTE_READWRITE);
|
||||
m_RecompCode = (BYTE *)VirtualAlloc(RecompCodeBase, InitialCompileBufferSize, MEM_COMMIT, PAGE_EXECUTE_READWRITE);
|
||||
if (m_RecompCode == NULL)
|
||||
{
|
||||
WriteTrace(TraceError,__FUNCTION__ ": failed to commit initial buffer");
|
||||
VirtualFree( RecompCodeBase, 0 , MEM_RELEASE);
|
||||
WriteTrace(TraceError, __FUNCTION__ ": failed to commit initial buffer");
|
||||
VirtualFree(RecompCodeBase, 0, MEM_RELEASE);
|
||||
g_Notify->DisplayError(MSG_MEM_ALLOC_ERROR);
|
||||
return false;
|
||||
}
|
||||
m_RecompSize = InitialCompileBufferSize;
|
||||
m_RecompPos = m_RecompCode;
|
||||
memset(m_RecompCode,0,InitialCompileBufferSize);
|
||||
memset(m_RecompCode, 0, InitialCompileBufferSize);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -63,14 +63,13 @@ void CRecompMemory::CheckRecompMem()
|
|||
g_Recompiler->ResetRecompCode(true);
|
||||
return;
|
||||
}
|
||||
LPVOID MemAddr = VirtualAlloc( m_RecompCode + m_RecompSize , IncreaseCompileBufferSize, MEM_COMMIT, PAGE_EXECUTE_READWRITE);
|
||||
LPVOID MemAddr = VirtualAlloc(m_RecompCode + m_RecompSize, IncreaseCompileBufferSize, MEM_COMMIT, PAGE_EXECUTE_READWRITE);
|
||||
if (MemAddr == NULL)
|
||||
{
|
||||
WriteTrace(TraceError,__FUNCTION__ ": failed to increase buffer");
|
||||
WriteTrace(TraceError, __FUNCTION__ ": failed to increase buffer");
|
||||
g_Notify->FatalError(MSG_MEM_ALLOC_ERROR);
|
||||
}
|
||||
m_RecompSize += IncreaseCompileBufferSize;
|
||||
|
||||
}
|
||||
|
||||
void CRecompMemory::Reset()
|
||||
|
@ -84,9 +83,9 @@ void CRecompMemory::ShowMemUsed()
|
|||
DWORD MB = Size / 0x100000;
|
||||
Size -= MB * 0x100000;
|
||||
DWORD KB = Size / 1024;
|
||||
Size -= KB * 1024;
|
||||
Size -= KB * 1024;
|
||||
|
||||
DWORD TotalAvaliable = m_RecompSize / 0x100000;
|
||||
|
||||
g_Notify->DisplayMessage(0,stdstr_f("Memory used: %d mb %-3d kb %-3d bytes Total Available: %d mb",MB,KB,Size, TotalAvaliable).ToUTF16().c_str());
|
||||
g_Notify->DisplayMessage(0, stdstr_f("Memory used: %d mb %-3d kb %-3d bytes Total Available: %d mb", MB, KB, Size, TotalAvaliable).ToUTF16().c_str());
|
||||
}
|
||||
|
|
|
@ -22,13 +22,16 @@ protected:
|
|||
void Reset();
|
||||
void ShowMemUsed();
|
||||
|
||||
BYTE* RecompPos() const { return m_RecompPos; }
|
||||
uint8_t* RecompPos() const { return m_RecompPos; }
|
||||
|
||||
private:
|
||||
BYTE * m_RecompCode;
|
||||
DWORD m_RecompSize;
|
||||
CRecompMemory(const CRecompMemory&); // Disable copy constructor
|
||||
CRecompMemory& operator=(const CRecompMemory&); // Disable assignment
|
||||
|
||||
enum { MaxCompileBufferSize = 0x03C00000 };
|
||||
enum { InitialCompileBufferSize = 0x00500000 };
|
||||
uint8_t * m_RecompCode;
|
||||
uint32_t m_RecompSize;
|
||||
|
||||
enum { MaxCompileBufferSize = 0x03C00000 };
|
||||
enum { InitialCompileBufferSize = 0x00500000 };
|
||||
enum { IncreaseCompileBufferSize = 0x00100000 };
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue