DOS_ResizeMemory() compact free blocks but only those from the segment that is being resized on, as MS-DOS is documented to do

This commit is contained in:
Jonathan Campbell
2025-10-06 23:12:32 -07:00
parent 213f7ba443
commit 16f4c85323
2 changed files with 5 additions and 5 deletions

View File

@@ -1,4 +1,6 @@
Next version
- INT 21h AH=4Ah resize memory: Compact free blocks only at or after the
segment being resized, as MS-DOS is documented to do (joncampbell123).
- INT 21h AH=4Ah resize memory: Fix bug where, if asked to resize a previously
freed memory block and the block is not the last block in the MCB chain,
and the next block in the MCB chain is also free, the MCB management code

View File

@@ -386,12 +386,10 @@ bool DOS_ResizeMemory(uint16_t segment,uint16_t * blocks) {
return false;
}
/* MS-DOS is documented to combine free blocks at or after this block. Also to avoid combining free blocks in a way
* that might invalidate the mcb() block we just constructed. */
uint16_t total=mcb.GetSize();
if (*blocks > total)
DOS_CompressMemory(segment-1);
else
DOS_CompressMemory();
/* DOS_CompressMemory() may change the MCB block size if this is a free block when it combines consecutive free blocks.
* If you don't think this could be a free block, understand that there are DOS applications and games out there