(the utmpentry.c code), specifically with respect to who owns them and
when to free them. Now they're owned by utmpentry.c, only. Abolish the
freeutentries() function, which was the wrong abstraction; add instead
endutentries(), which flushes out the internally managed memory.
Update callers as necessary. Some (e.g. talkd) had been leaking memory;
others (e.g. syslogd) had been accidentally freeing and reloading utmp
more often than necessary. There are a couple untidy bits in users and
rwhod that someone should look after sometime, maybe.
Fixes PR bin/35131, which was about talkd's memory leak.
-/* $NetBSD: dm.c,v 1.24 2007/12/15 19:44:40 perry Exp $ */
+/* $NetBSD: dm.c,v 1.25 2008/07/13 20:07:48 dholland Exp $ */
/*
* Copyright (c) 1987, 1993
#if 0
static char sccsid[] = "@(#)dm.c 8.1 (Berkeley) 5/31/93";
#else
-__RCSID("$NetBSD: dm.c,v 1.24 2007/12/15 19:44:40 perry Exp $");
+__RCSID("$NetBSD: dm.c,v 1.25 2008/07/13 20:07:48 dholland Exp $");
#endif
#endif /* not lint */
int
users(void)
{
- static struct utmpentry *ohead = NULL;
struct utmpentry *ep;
int nusers;
nusers = getutentries(NULL, &ep);
- if (ep != ohead) {
- freeutentries(ep);
- ohead = ep;
- }
return nusers;
}