malloc returns 0 on out of memory, not -1 as in version 6.
authorPeter B. Kessler <peter@ucbvax.Berkeley.EDU>
Tue, 25 Nov 1980 11:00:10 +0000 (03:00 -0800)
committerPeter B. Kessler <peter@ucbvax.Berkeley.EDU>
Tue, 25 Nov 1980 11:00:10 +0000 (03:00 -0800)
SCCS-vsn: usr.bin/pascal/src/case.c 1.2
SCCS-vsn: usr.bin/pascal/src/hash.c 1.2
SCCS-vsn: usr.bin/pascal/src/nl.c 1.4
SCCS-vsn: usr.bin/pascal/src/string.c 1.2
SCCS-vsn: usr.bin/pascal/src/subr.c 1.3
SCCS-vsn: usr.bin/pascal/src/tree.c 1.2

usr/src/usr.bin/pascal/src/case.c
usr/src/usr.bin/pascal/src/hash.c
usr/src/usr.bin/pascal/src/nl.c
usr/src/usr.bin/pascal/src/string.c
usr/src/usr.bin/pascal/src/subr.c
usr/src/usr.bin/pascal/src/tree.c

index 8f6100f..4b5b77d 100644 (file)
@@ -1,6 +1,6 @@
 /* Copyright (c) 1979 Regents of the University of California */
 
 /* Copyright (c) 1979 Regents of the University of California */
 
-static char sccsid[] = "@(#)case.c 1.1 %G%";
+static char sccsid[] = "@(#)case.c 1.2 %G%";
 
 #include "whoami.h"
 #include "0.h"
 
 #include "whoami.h"
 #include "0.h"
@@ -81,7 +81,7 @@ caseop(r)
         * Allocate case table space
         */
        ctab = i = malloc(n * sizeof *ctab);
         * Allocate case table space
         */
        ctab = i = malloc(n * sizeof *ctab);
-       if (i == -1) {
+       if (i == 0) {
                error("Ran out of memory (case)");
                pexit(DIED);
        }
                error("Ran out of memory (case)");
                pexit(DIED);
        }
index 6c497e1..c391ecc 100644 (file)
@@ -1,6 +1,6 @@
 /* Copyright (c) 1979 Regents of the University of California */
 
 /* Copyright (c) 1979 Regents of the University of California */
 
-static char sccsid[] = "@(#)hash.c 1.1 %G%";
+static char sccsid[] = "@(#)hash.c 1.2 %G%";
 
 #include "whoami.h"
 #include "0.h"
 
 #include "whoami.h"
 #include "0.h"
@@ -136,7 +136,7 @@ int *hash(s, save)
        for (htp = htab; htp < &htab[MAXHASH]; htp++) {
                if (htp->ht_low == NIL) {
                        cp = (char *) calloc(sizeof ( int * ), HASHINC);
        for (htp = htab; htp < &htab[MAXHASH]; htp++) {
                if (htp->ht_low == NIL) {
                        cp = (char *) calloc(sizeof ( int * ), HASHINC);
-                       if (cp == -1) {
+                       if (cp == 0) {
                                yerror("Ran out of memory (hash)");
                                pexit(DIED);
                        }
                                yerror("Ran out of memory (hash)");
                                pexit(DIED);
                        }
index b73105c..e065629 100644 (file)
@@ -1,6 +1,6 @@
 /* Copyright (c) 1979 Regents of the University of California */
 
 /* Copyright (c) 1979 Regents of the University of California */
 
-static char sccsid[] = "@(#)nl.c 1.3 %G%";
+static char sccsid[] = "@(#)nl.c 1.4 %G%";
 
 #include "whoami.h"
 #include "0.h"
 
 #include "whoami.h"
 #include "0.h"
@@ -680,11 +680,11 @@ defnl(sym, cls, typ, val)
        if (nlp >= nlact->nls_high) {
                i = NLINC;
                cp = malloc(NLINC * sizeof *nlp);
        if (nlp >= nlact->nls_high) {
                i = NLINC;
                cp = malloc(NLINC * sizeof *nlp);
-               if (cp == -1) {
+               if (cp == 0) {
                        i = NLINC / 2;
                        cp = malloc((NLINC / 2) * sizeof *nlp);
                }
                        i = NLINC / 2;
                        cp = malloc((NLINC / 2) * sizeof *nlp);
                }
-               if (cp == -1) {
+               if (cp == 0) {
                        error("Ran out of memory (defnl)");
                        pexit(DIED);
                }
                        error("Ran out of memory (defnl)");
                        pexit(DIED);
                }
index 21f1701..60b7c60 100644 (file)
@@ -1,6 +1,6 @@
 /* Copyright (c) 1979 Regents of the University of California */
 
 /* Copyright (c) 1979 Regents of the University of California */
 
-static char sccsid[] = "@(#)string.c 1.1 %G%";
+static char sccsid[] = "@(#)string.c 1.2 %G%";
 
 #include "whoami.h"
 #include "0.h"
 
 #include "whoami.h"
 #include "0.h"
@@ -64,7 +64,7 @@ savestr(cp)
        i = strlen(cp) + 1;
        if (strngp + i >= strng + STRINC) {
                strngp = malloc(STRINC);
        i = strlen(cp) + 1;
        if (strngp + i >= strng + STRINC) {
                strngp = malloc(STRINC);
-               if (strngp == -1) {
+               if (strngp == 0) {
                        yerror("Ran out of memory (string)");
                        pexit(DIED);
                }
                        yerror("Ran out of memory (string)");
                        pexit(DIED);
                }
index 3056f8b..5da90f0 100644 (file)
@@ -1,6 +1,6 @@
 /* Copyright (c) 1979 Regents of the University of California */
 
 /* Copyright (c) 1979 Regents of the University of California */
 
-static char sccsid[] = "@(#)subr.c 1.2 %G%";
+static char sccsid[] = "@(#)subr.c 1.3 %G%";
 
 #include "whoami.h"
 #include "0.h"
 
 #include "whoami.h"
 #include "0.h"
@@ -113,8 +113,8 @@ calloc(num, size)
        register int p1, *p2, nbyte;
 
        nbyte = (num*size+( ( sizeof ( int ) ) - 1 ) ) & ~( ( sizeof ( int ) ) - 1 );
        register int p1, *p2, nbyte;
 
        nbyte = (num*size+( ( sizeof ( int ) ) - 1 ) ) & ~( ( sizeof ( int ) ) - 1 );
-       if ((p1 = malloc(nbyte)) == -1 || p1==0)
-               return (-1);
+       if ((p1 = malloc(nbyte)) == 0)
+               return (0);
        p2 = p1;
        nbyte /= sizeof ( int );
        do {
        p2 = p1;
        nbyte /= sizeof ( int );
        do {
index 42764f3..e754396 100644 (file)
@@ -1,6 +1,6 @@
 /* Copyright (c) 1979 Regents of the University of California */
 
 /* Copyright (c) 1979 Regents of the University of California */
 
-static char sccsid[] = "@(#)tree.c 1.1 %G%";
+static char sccsid[] = "@(#)tree.c 1.2 %G%";
 
 #include "whoami.h"
 #include "0.h"
 
 #include "whoami.h"
 #include "0.h"
@@ -106,7 +106,7 @@ tralloc(howmuch)
        if (spacep + howmuch >= tract->tr_high) {
                i = TRINC;
                cp = malloc(i * sizeof ( int ));
        if (spacep + howmuch >= tract->tr_high) {
                i = TRINC;
                cp = malloc(i * sizeof ( int ));
-               if (cp == -1) {
+               if (cp == 0) {
                        yerror("Ran out of memory (tralloc)");
                        pexit(DIED);
                }
                        yerror("Ran out of memory (tralloc)");
                        pexit(DIED);
                }