Added No_Mem
This commit is contained in:
parent
f98832f587
commit
398021e77a
|
@ -10,9 +10,10 @@ SOURCES = alloc.h\
|
|||
botch.c\
|
||||
clear.c\
|
||||
st_alloc.c\
|
||||
std_alloc.c
|
||||
std_alloc.c \
|
||||
No_Mem.c
|
||||
|
||||
OBJECTS = botch.o clear.o st_alloc.o Malloc.o std_alloc.o
|
||||
OBJECTS = botch.o clear.o st_alloc.o Malloc.o std_alloc.o No_Mem.o
|
||||
|
||||
all: liballoc.a
|
||||
|
||||
|
|
|
@ -14,20 +14,13 @@
|
|||
#include "in_all.h"
|
||||
#include "alloc.h"
|
||||
|
||||
PRIVATE
|
||||
m_fatal() {
|
||||
|
||||
(void) sys_write(2, "Out of memory\n", 14);
|
||||
sys_stop(S_EXIT);
|
||||
}
|
||||
|
||||
EXPORT char *
|
||||
Malloc(sz)
|
||||
unsigned int sz;
|
||||
{
|
||||
char *res = malloc(sz);
|
||||
|
||||
if (res == 0) m_fatal();
|
||||
if (res == 0) No_Mem();
|
||||
return res;
|
||||
}
|
||||
|
||||
|
@ -42,7 +35,7 @@ Salloc(str, sz)
|
|||
char *res = malloc(sz);
|
||||
register char *m = res;
|
||||
|
||||
if (m == 0) m_fatal();
|
||||
if (m == 0) No_Mem();
|
||||
while (sz--)
|
||||
*m++ = *str++;
|
||||
return res;
|
||||
|
@ -54,6 +47,6 @@ Srealloc(str, sz)
|
|||
unsigned int sz;
|
||||
{
|
||||
str = realloc(str, sz);
|
||||
if (str == 0) m_fatal();
|
||||
if (str == 0) No_Mem();
|
||||
return str;
|
||||
}
|
||||
|
|
|
@ -70,4 +70,6 @@ These last two routines are best used in a macro.
|
|||
malloc(3)
|
||||
.SH DIAGNOSTICS
|
||||
\fIMalloc\fR, \fISalloc\fR, \fISrealloc\fR, and \fIst_alloc\fR
|
||||
give an error message and stop execution if there is no memory available.
|
||||
call a routine \fINo_Mem\fR if there is no memory available. This routine
|
||||
is not supposed to return. A default one, that
|
||||
gives an error message and stops execution, is provided.
|
||||
|
|
Loading…
Reference in a new issue