1
0
Fork 0

add error handling for DOS_SetMemAllocStrategy

Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@2385
This commit is contained in:
Sebastian Strohhäcker 2005-11-24 17:05:22 +00:00
parent 2eb59a43e3
commit 96bf0e28d6
3 changed files with 19 additions and 12 deletions

View file

@ -16,7 +16,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
/* $Id: dos_inc.h,v 1.57 2005-11-07 21:08:11 c2woody Exp $ */
/* $Id: dos_inc.h,v 1.58 2005-11-24 17:05:19 c2woody Exp $ */
#ifndef DOSBOX_DOS_INC_H
#define DOSBOX_DOS_INC_H
@ -156,7 +156,7 @@ bool DOS_ResizeMemory(Bit16u segment,Bit16u * blocks);
bool DOS_FreeMemory(Bit16u segment);
void DOS_FreeProcessMemory(Bit16u pspseg);
Bit16u DOS_GetMemory(Bit16u pages);
void DOS_SetMemAllocStrategy(Bit16u strat);
bool DOS_SetMemAllocStrategy(Bit16u strat);
Bit16u DOS_GetMemAllocStrategy(void);
void DOS_BuildUMBChain(const char* use_umbs,bool ems_active);
bool DOS_LinkUMBsToMemChain(Bit16u linkstate);

View file

@ -16,7 +16,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
/* $Id: dos.cpp,v 1.89 2005-11-17 13:16:34 qbix79 Exp $ */
/* $Id: dos.cpp,v 1.90 2005-11-24 17:05:22 c2woody Exp $ */
#include <stdlib.h>
#include <string.h>
@ -720,7 +720,11 @@ static Bitu DOS_21Handler(void) {
reg_ax=DOS_GetMemAllocStrategy();
break;
case 1: /* Set Strategy */
DOS_SetMemAllocStrategy(reg_bx);
if (DOS_SetMemAllocStrategy(reg_bx)) CALLBACK_SCF(false);
else {
reg_ax=1;
CALLBACK_SCF(true);
}
break;
case 2: /* Get UMB Link Status */
reg_al=dos_infoblock.GetUMBChainState()&1;

View file

@ -68,17 +68,20 @@ void DOS_FreeProcessMemory(Bit16u pspseg) {
} else if (umb_start!=0xffff) LOG(LOG_DOSMISC,LOG_ERROR)("Corrupt UMB chain: %x",umb_start);
DOS_CompressMemory();
};
}
Bit16u DOS_GetMemAllocStrategy()
{
Bit16u DOS_GetMemAllocStrategy() {
return memAllocStrategy;
};
}
void DOS_SetMemAllocStrategy(Bit16u strat)
{
memAllocStrategy = strat;
};
bool DOS_SetMemAllocStrategy(Bit16u strat) {
if ((strat&0x3f)<3) {
memAllocStrategy = strat;
return true;
}
/* otherwise an invalid allocation strategy was specified */
return false;
}
bool DOS_AllocateMemory(Bit16u * segment,Bit16u * blocks) {
DOS_CompressMemory();