diff options
author | Ted Unangst <tedu@cvs.openbsd.org> | 2003-09-26 22:24:10 +0000 |
---|---|---|
committer | Ted Unangst <tedu@cvs.openbsd.org> | 2003-09-26 22:24:10 +0000 |
commit | 17738dcbee8bacfd8a68cd4375820c4947ff55d6 (patch) | |
tree | 37af77e881cde2f3b424047b2aabd080ab96328b /usr.bin/indent/lexi.c | |
parent | 620a0222f490c8fe0d8dfc7b15279733cfed0593 (diff) |
better realloc. ok deraadt@ henning@
Diffstat (limited to 'usr.bin/indent/lexi.c')
-rw-r--r-- | usr.bin/indent/lexi.c | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/usr.bin/indent/lexi.c b/usr.bin/indent/lexi.c index 774ca6b7d9a..fa62b4740a6 100644 --- a/usr.bin/indent/lexi.c +++ b/usr.bin/indent/lexi.c @@ -1,4 +1,4 @@ -/* $OpenBSD: lexi.c,v 1.9 2003/06/12 01:07:27 deraadt Exp $ */ +/* $OpenBSD: lexi.c,v 1.10 2003/09/26 22:23:28 tedu Exp $ */ /* * Copyright (c) 1980, 1993 @@ -34,7 +34,7 @@ #ifndef lint /*static char sccsid[] = "@(#)lexi.c 8.1 (Berkeley) 6/6/93";*/ -static char rcsid[] = "$OpenBSD: lexi.c,v 1.9 2003/06/12 01:07:27 deraadt Exp $"; +static char rcsid[] = "$OpenBSD: lexi.c,v 1.10 2003/09/26 22:23:28 tedu Exp $"; #endif /* not lint */ /* @@ -589,10 +589,14 @@ addkey(key, val) err(1, NULL); memmove(specials, specialsinit, sizeof specialsinit); } else if (nspecials >= maxspecials) { - maxspecials += maxspecials >> 2; - specials = realloc(specials, maxspecials * sizeof specials[0]); - if (specials == NULL) + int newspecials = maxspecials + maxspecials >> 2; + struct templ *specials2; + + specials2 = realloc(specials, newspecials * sizeof specials[0]); + if (specials2 == NULL) err(1, NULL); + specials = specials2; + maxspecials = newspecials; } p = &specials[i]; |