Safer memory allocation

This commit is contained in:
pagefault
2003-10-31 17:39:20 +00:00
parent 632a8fb461
commit fd0480c7e5
2 changed files with 19 additions and 2 deletions

View File

@@ -664,7 +664,11 @@ NEWSYM allocptr
; cmp byte[OSPort],3
; jne near .nostate
%ifndef __MSDOS__
AllocmemFail 4096*128*16+4096+65536*16,StateBackup,outofmemory
EXTSYM allocblah
pushad
call allocblah
popad
; AllocmemFail 4096*128*16+4096+65536*16,StateBackup,outofmemory
mov eax,[StateBackup]
add eax,4096*128*16
mov [BitConv32Ptr],eax

View File

@@ -24,9 +24,22 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#define true 1
#define false 0
extern void outofmemory();
extern int *spc7110romptr;
extern int *StateBackup;
extern int *spcBuffera;
int doMemAlloc(int *ptr, int size)
{
int result = 0;
ptr = malloc(size);
if (ptr) result = 1;
return result;
}
void allocspc7110()
{
spc7110romptr = malloc(8192*1024+4096);
if (!doMemAlloc(spc7110romptr, 8192*1024+4096)) outofmemory();
}