The LazyBoy Library Manual - DOS_Resize

Part of the Memory Management group.

%imacro DOS_Resize 2
Prefers: ES, BX

Resize a DOS memory block.

%1 is the segment of memory block to resize.

%2 is the requested new paragraph size for the memory block.

If successful on return, the Carry Flag will be clear.

If not successful because there was insufficient memory available, the Carry Flag will be set and the new block size will be returned as %2.

There are only two other possible reason for the request fail. The first is when the segment provided is not a valid memory block address and is most likely a program bug. The second reason is when the MCB chain has been damaged. If the MCB chain is damaged, the operating system is unstable and will require a reboot. Either of those errors is very bad.

If the MCB chain is damaged or an invalid segment error occurs and DEBUG is enabled, the program will Terminate with an error code. If DEBUG is not enabled, the macro will store the error in EXIT_CODE. Then return with the Carry flag set and a new size of zero. The program should shut down as soon as possible. I may change this behaviour to always Terminate the program if either of these errors occurs.

Caution: If you want to resize the memory allocated to the program and it uses the memory heap, it is highly recommended you resize the memory allocated before activating the heap. This will remove the need to calculate the appropriate maximum size for the memory heap.

Example:

    DOS_Resize ES, BX       ; resize segment ES

See also: DOS_Alloc and DOS_Release and EXIT_CODE.