SVN r3895 (partial)

Coalesce free memory blocks before resizing a block in case it grows; coalesce after resizing only if the block shrinks.
This commit is contained in:
Allofich 2019-04-30 14:27:40 +09:00
parent f8c9d50c11
commit 575ba6749d

View File

@ -327,11 +327,12 @@ bool DOS_ResizeMemory(Bit16u segment,Bit16u * blocks) {
if (*blocks > total)
DOS_CompressMemory(segment-1);
else
DOS_CompressMemory();
if (*blocks<=total) {
if (GCC_UNLIKELY(*blocks==total)) {
/* Nothing to do */
DOS_CompressMemory();
return true;
}
/* Shrinking MCB */
@ -367,7 +368,6 @@ bool DOS_ResizeMemory(Bit16u segment,Bit16u * blocks) {
mcb_next.SetPSPSeg(MCB_FREE);
mcb.SetType(0x4d);
mcb.SetPSPSeg(dos.psp());
DOS_CompressMemory();
return true;
}
@ -380,7 +380,6 @@ bool DOS_ResizeMemory(Bit16u segment,Bit16u * blocks) {
}
mcb.SetSize(total);
mcb.SetPSPSeg(dos.psp());
DOS_CompressMemory();
if (*blocks==total) return true; /* block fit exactly */
*blocks=total; /* return maximum */