diff options
author | 2003-09-26 07:15:41 +0000 | |
---|---|---|
committer | 2003-09-26 07:15:41 +0000 | |
commit | 160a244b2598c43b53aefe003ee2d8ea4e9964c9 (patch) | |
tree | 4702e90dce03cecfb31beba9eba51d71ddeebed8 | |
parent | spacing (diff) | |
download | wireguard-openbsd-160a244b2598c43b53aefe003ee2d8ea4e9964c9.tar.xz wireguard-openbsd-160a244b2598c43b53aefe003ee2d8ea4e9964c9.zip |
realloc tuning; pvalchev ok
-rw-r--r-- | usr.sbin/rwhod/rwhod.c | 13 |
1 files changed, 5 insertions, 8 deletions
diff --git a/usr.sbin/rwhod/rwhod.c b/usr.sbin/rwhod/rwhod.c index a5ec8ec4d2d..aab647fbe28 100644 --- a/usr.sbin/rwhod/rwhod.c +++ b/usr.sbin/rwhod/rwhod.c @@ -35,7 +35,7 @@ static char copyright[] = #ifndef lint /*static char sccsid[] = "@(#)rwhod.c 8.1 (Berkeley) 6/6/93";*/ -static char rcsid[] = "$OpenBSD: rwhod.c,v 1.28 2003/06/08 17:05:36 mickey Exp $"; +static char rcsid[] = "$OpenBSD: rwhod.c,v 1.29 2003/09/26 07:15:41 deraadt Exp $"; #endif /* not lint */ #include <sys/param.h> @@ -355,19 +355,16 @@ timer(void) if ((stb.st_mtime != utmptime) || (stb.st_size > utmpsize)) { utmptime = stb.st_mtime; if (stb.st_size > utmpsize) { - utmpsize = stb.st_size + 10 * sizeof(struct utmp); - if (utmp) - nutmp = (struct utmp *)realloc(utmp, utmpsize); - else - nutmp = (struct utmp *)malloc(utmpsize); + int nutmpsize = stb.st_size + 10 * sizeof(struct utmp); + nutmp = (struct utmp *)realloc(utmp, nutmpsize); if (!nutmp) { warnx("malloc failed"); - if (utmp) - free(utmp); + free(utmp); utmpsize = 0; return; } utmp = nutmp; + utmpsize = nutmpsize; } (void) lseek(utmpf, (off_t)0, SEEK_SET); cc = read(utmpf, (char *)utmp, stb.st_size); |