Safer memory allocation
This commit is contained in:
@@ -664,7 +664,11 @@ NEWSYM allocptr
|
|||||||
; cmp byte[OSPort],3
|
; cmp byte[OSPort],3
|
||||||
; jne near .nostate
|
; jne near .nostate
|
||||||
%ifndef __MSDOS__
|
%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]
|
mov eax,[StateBackup]
|
||||||
add eax,4096*128*16
|
add eax,4096*128*16
|
||||||
mov [BitConv32Ptr],eax
|
mov [BitConv32Ptr],eax
|
||||||
|
|||||||
@@ -24,9 +24,22 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|||||||
#define true 1
|
#define true 1
|
||||||
#define false 0
|
#define false 0
|
||||||
|
|
||||||
|
extern void outofmemory();
|
||||||
extern int *spc7110romptr;
|
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()
|
void allocspc7110()
|
||||||
{
|
{
|
||||||
spc7110romptr = malloc(8192*1024+4096);
|
if (!doMemAlloc(spc7110romptr, 8192*1024+4096)) outofmemory();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user