On memory allocation failure, return 3 as per POSIX. (from OpenBSD)

This commit is contained in:
mjl 2000-01-14 07:14:41 +00:00
parent ec1d133cd3
commit 5a14e8cac6
2 changed files with 7 additions and 5 deletions

View File

@ -1,4 +1,4 @@
.\" $NetBSD: expr.1,v 1.10 1997/10/20 08:51:56 enami Exp $
.\" $NetBSD: expr.1,v 1.11 2000/01/14 07:14:41 mjl Exp $
.\"
.\" Written by J.T. Conklin <jtc@netbsd.org>.
.\" Public domain.
@ -97,6 +97,8 @@ the expression is neither an empty string nor 0.
the expression is an empty string or 0.
.It 2
the expression is invalid.
.It >2
an error occurred (such as memory allocation failure).
.El
.Sh STANDARDS
The

View File

@ -1,4 +1,4 @@
/* $NetBSD: expr.c,v 1.11 1999/11/09 15:06:31 drochner Exp $ */
/* $NetBSD: expr.c,v 1.12 2000/01/14 07:14:41 mjl Exp $ */
/*
* Written by J.T. Conklin <jtc@netbsd.org>.
@ -62,7 +62,7 @@ make_int(i)
vp = (struct val *) malloc(sizeof(*vp));
if (vp == NULL) {
err(2, NULL);
err(3, NULL);
}
vp->type = integer;
vp->u.i = i;
@ -78,7 +78,7 @@ make_str(s)
vp = (struct val *) malloc(sizeof(*vp));
if (vp == NULL || ((vp->u.s = strdup(s)) == NULL)) {
err(2, NULL);
err(3, NULL);
}
vp->type = string;
return vp;
@ -172,7 +172,7 @@ to_string(vp)
tmp = malloc(25);
if (tmp == NULL) {
err(2, NULL);
err(3, NULL);
}
(void)snprintf(tmp, 25, "%d", vp->u.i);
vp->type = string;