diff options
author | Marc Espie <espie@cvs.openbsd.org> | 2003-11-17 17:12:11 +0000 |
---|---|---|
committer | Marc Espie <espie@cvs.openbsd.org> | 2003-11-17 17:12:11 +0000 |
commit | 8123f40990baf77b89e1f4568718232fed905077 (patch) | |
tree | 7ffaf16232568f653eabbfcfd6fda43ada4472fc /usr.bin/m4/main.c | |
parent | f4f786080bd710064f8cba8c6f613957974800fd (diff) |
Modify xalloc so that it also takes err(3)-like arguments.
Write an xrealloc wrapper that works the same way, and use it as well.
People who feel like it may want to add more explicit error messages to
all the places m4 can fail allocating memory...
okay tedu@
Diffstat (limited to 'usr.bin/m4/main.c')
-rw-r--r-- | usr.bin/m4/main.c | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/usr.bin/m4/main.c b/usr.bin/m4/main.c index 415f1c9f60c..04ea0dcf4ef 100644 --- a/usr.bin/m4/main.c +++ b/usr.bin/m4/main.c @@ -1,4 +1,4 @@ -/* $OpenBSD: main.c,v 1.63 2003/06/30 22:13:32 espie Exp $ */ +/* $OpenBSD: main.c,v 1.64 2003/11/17 17:12:10 espie Exp $ */ /* $NetBSD: main.c,v 1.12 1997/02/08 23:54:49 cgd Exp $ */ /*- @@ -43,7 +43,7 @@ static char copyright[] = #if 0 static char sccsid[] = "@(#)main.c 8.1 (Berkeley) 6/6/93"; #else -static char rcsid[] = "$OpenBSD: main.c,v 1.63 2003/06/30 22:13:32 espie Exp $"; +static char rcsid[] = "$OpenBSD: main.c,v 1.64 2003/11/17 17:12:10 espie Exp $"; #endif #endif /* not lint */ @@ -191,8 +191,8 @@ main(int argc, char *argv[]) initspaces(); STACKMAX = INITSTACKMAX; - mstack = (stae *)xalloc(sizeof(stae) * STACKMAX); - sstack = (char *)xalloc(STACKMAX); + mstack = (stae *)xalloc(sizeof(stae) * STACKMAX, NULL); + sstack = (char *)xalloc(STACKMAX, NULL); maxout = 0; outfile = NULL; @@ -623,10 +623,11 @@ dump_stack(struct position *t, int lev) static void enlarge_stack(void) { - STACKMAX *= 2; - mstack = realloc(mstack, sizeof(stae) * STACKMAX); - sstack = realloc(sstack, STACKMAX); - if (mstack == NULL || sstack == NULL) - errx(1, "Evaluation stack overflow (%lu)", - (unsigned long)STACKMAX); + STACKMAX += STACKMAX/2; + mstack = xrealloc(mstack, sizeof(stae) * STACKMAX, + "Evaluation stack overflow (%lu)", + (unsigned long)STACKMAX); + sstack = xrealloc(sstack, STACKMAX, + "Evaluation stack overflow (%lu)", + (unsigned long)STACKMAX); } |