Added No_Mem
authorceriel <none@none>
Mon, 23 Feb 1987 11:38:15 +0000 (11:38 +0000)
committerceriel <none@none>
Mon, 23 Feb 1987 11:38:15 +0000 (11:38 +0000)
modules/src/alloc/Makefile
modules/src/alloc/Malloc.c
modules/src/alloc/alloc.3

index 2593425..964238a 100644 (file)
@@ -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
 
index 97b7cdd..63dee38 100644 (file)
 #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;
 }
index 3a71beb..5afc88f 100644 (file)
@@ -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.