summaryrefslogtreecommitdiffstats
path: root/dm/dm.c
diff options
context:
space:
mode:
authordholland <dholland@NetBSD.org>2008-07-13 20:07:48 +0000
committerdholland <dholland@NetBSD.org>2008-07-13 20:07:48 +0000
commitee6e757230838de21b94218e463f2d43979e3aa9 (patch)
tree714e712b55413d68f61714386c434219435b7c4c /dm/dm.c
parentd149b63903bb1ba899975d53b8a1a522a91c9921 (diff)
downloadbsdgames-darwin-ee6e757230838de21b94218e463f2d43979e3aa9.tar.gz
bsdgames-darwin-ee6e757230838de21b94218e463f2d43979e3aa9.tar.zst
bsdgames-darwin-ee6e757230838de21b94218e463f2d43979e3aa9.zip
Clarify how one is supposed to use the pointers returned by getutentries()
(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.
Diffstat (limited to 'dm/dm.c')
-rw-r--r--dm/dm.c9
1 files changed, 2 insertions, 7 deletions
diff --git a/dm/dm.c b/dm/dm.c
index 2518c369..24833da5 100644
--- a/dm/dm.c
+++ b/dm/dm.c
@@ -1,4 +1,4 @@
-/* $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
@@ -39,7 +39,7 @@ __COPYRIGHT("@(#) Copyright (c) 1987, 1993\n\
#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 */
@@ -247,15 +247,10 @@ load(void)
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;
}