unbiased the algorithm from just checking if only 4 or 8 MB

This commit is contained in:
unknown 2015-07-18 13:12:40 -04:00
parent 188091e32a
commit 51975fb00d
1 changed files with 17 additions and 5 deletions

View File

@ -5379,15 +5379,27 @@ void CMipsMemoryVM::RdramChanged ( CMipsMemoryVM * _this )
{
return;
}
if (old_size == 0x800000)
if (old_size > new_size)
{
VirtualFree(_this->m_RDRAM + 0x400000, 0x400000, MEM_DECOMMIT);
VirtualFree(
_this->m_RDRAM + new_size,
old_size - new_size,
MEM_DECOMMIT
);
}
else
{
if (VirtualAlloc(_this->m_RDRAM + 0x400000, 0x400000, MEM_COMMIT, PAGE_READWRITE)==NULL)
{
void * result;
result = VirtualAlloc(
_this->m_RDRAM + old_size,
new_size - old_size,
MEM_COMMIT,
PAGE_READWRITE
);
if (result == NULL)
{
WriteTrace(TraceError,__FUNCTION__ ": failed to allocate extended memory");
WriteTrace(TraceError, __FUNCTION__": failed to allocate extended memory");
g_Notify -> FatalError(GS(MSG_MEM_ALLOC_ERROR));
}
}