From: ceriel Date: Mon, 23 Feb 1987 11:38:15 +0000 (+0000) Subject: Added No_Mem X-Git-Tag: release-5-5~4646 X-Git-Url: https://git.ndcode.org/public/gitweb.cgi?a=commitdiff_plain;h=398021e77a2511dc05185f2216a56e695c26f9c5;p=ack.git Added No_Mem --- diff --git a/modules/src/alloc/Makefile b/modules/src/alloc/Makefile index 259342504..964238a9c 100644 --- a/modules/src/alloc/Makefile +++ b/modules/src/alloc/Makefile @@ -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 diff --git a/modules/src/alloc/Malloc.c b/modules/src/alloc/Malloc.c index 97b7cddfd..63dee3880 100644 --- a/modules/src/alloc/Malloc.c +++ b/modules/src/alloc/Malloc.c @@ -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; } diff --git a/modules/src/alloc/alloc.3 b/modules/src/alloc/alloc.3 index 3a71beb20..5afc88fcc 100644 --- a/modules/src/alloc/alloc.3 +++ b/modules/src/alloc/alloc.3 @@ -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.