diff options
author | Theo de Raadt <deraadt@cvs.openbsd.org> | 2003-09-26 07:15:42 +0000 |
---|---|---|
committer | Theo de Raadt <deraadt@cvs.openbsd.org> | 2003-09-26 07:15:42 +0000 |
commit | 6eaf622ca872513a384b705cdd35c8d1360dd06a (patch) | |
tree | 9a23c505af0f3b02b43a716d9e0569ddfb835b84 /usr.sbin | |
parent | 1f59dd3b334e8678abb964a88a2d8874b9f40789 (diff) |
realloc tuning; pvalchev ok
Diffstat (limited to 'usr.sbin')
-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); |