diff options
author | 2007-05-29 00:19:10 +0000 | |
---|---|---|
committer | 2007-05-29 00:19:10 +0000 | |
commit | 80566be2fd42462c257a810a11ee376aa6a91bc8 (patch) | |
tree | 99f1119e0c13ee6c88f8fe6b86965e56437131b3 /usr.bin/cvs/diff3.c | |
parent | Add a name argument to the RWLOCK_INITIALIZER macro. (diff) | |
download | wireguard-openbsd-80566be2fd42462c257a810a11ee376aa6a91bc8.tar.xz wireguard-openbsd-80566be2fd42462c257a810a11ee376aa6a91bc8.zip |
Since xrealloc dies on failure it is safe to directly assign to the
original pointer. Theo agrees, and so does the rest of the tree
(ssh, etc. all do this already).
Saves a bunch of variables and assignments.
OK niallo@
Diffstat (limited to 'usr.bin/cvs/diff3.c')
-rw-r--r-- | usr.bin/cvs/diff3.c | 30 |
1 files changed, 11 insertions, 19 deletions
diff --git a/usr.bin/cvs/diff3.c b/usr.bin/cvs/diff3.c index 5f573c49ddf..3479f4f822e 100644 --- a/usr.bin/cvs/diff3.c +++ b/usr.bin/cvs/diff3.c @@ -1,4 +1,4 @@ -/* $OpenBSD: diff3.c,v 1.35 2007/02/22 06:42:09 otto Exp $ */ +/* $OpenBSD: diff3.c,v 1.36 2007/05/29 00:19:10 ray Exp $ */ /* * Copyright (C) Caldera International Inc. 2001-2002. @@ -72,7 +72,7 @@ static const char copyright[] = #ifndef lint static const char rcsid[] = - "$OpenBSD: diff3.c,v 1.35 2007/02/22 06:42:09 otto Exp $"; + "$OpenBSD: diff3.c,v 1.36 2007/05/29 00:19:10 ray Exp $"; #endif /* not lint */ #include <ctype.h> @@ -492,12 +492,10 @@ getline(FILE *b, size_t *n) if (cp[len - 1] != '\n') len++; if (len + 1 > bufsize) { - char *newbuf; do { bufsize += 1024; } while (len + 1 > bufsize); - newbuf = xrealloc(buf, 1, bufsize); - buf = newbuf; + buf = xrealloc(buf, 1, bufsize); } memcpy(buf, cp, len - 1); buf[len - 1] = '\n'; @@ -789,25 +787,19 @@ edscript(int n) static void increase(void) { - struct diff *p; - char *q; size_t newsz, incr; /* are the memset(3) calls needed? */ newsz = szchanges == 0 ? 64 : 2 * szchanges; incr = newsz - szchanges; - p = xrealloc(d13, newsz, sizeof(*d13)); - memset(p + szchanges, 0, incr * sizeof(*d13)); - d13 = p; - p = xrealloc(d23, newsz, sizeof(*d23)); - memset(p + szchanges, 0, incr * sizeof(*d23)); - d23 = p; - p = xrealloc(de, newsz, sizeof(*de)); - memset(p + szchanges, 0, incr * sizeof(*de)); - de = p; - q = xrealloc(overlap, newsz, sizeof(*overlap)); - memset(q + szchanges, 0, incr * sizeof(*overlap)); - overlap = q; + d13 = xrealloc(d13, newsz, sizeof(*d13)); + memset(d13 + szchanges, 0, incr * sizeof(*d13)); + d23 = xrealloc(d23, newsz, sizeof(*d23)); + memset(d23 + szchanges, 0, incr * sizeof(*d23)); + de = xrealloc(de, newsz, sizeof(*de)); + memset(de + szchanges, 0, incr * sizeof(*de)); + overlap = xrealloc(overlap, newsz, sizeof(*overlap)); + memset(overlap + szchanges, 0, incr * sizeof(*overlap)); szchanges = newsz; } |