diff options
author | ed <ed@FreeBSD.org> | 2012-09-12 22:16:31 +0000 |
---|---|---|
committer | ed <ed@FreeBSD.org> | 2012-09-12 22:16:31 +0000 |
commit | 56b44313f3830ccd19576c3574bbc339ad2522ad (patch) | |
tree | c9e9ec90b88b1bde67965201e2ccf02d86bc8c78 /usr.bin/last | |
parent | a634dfc320608f9955ab0350a7f78ee73064b909 (diff) | |
download | FreeBSD-src-56b44313f3830ccd19576c3574bbc339ad2522ad.zip FreeBSD-src-56b44313f3830ccd19576c3574bbc339ad2522ad.tar.gz |
Switch batch to an SLIST.
This code requires none of the features of LIST.
Diffstat (limited to 'usr.bin/last')
-rw-r--r-- | usr.bin/last/last.c | 20 |
1 files changed, 9 insertions, 11 deletions
diff --git a/usr.bin/last/last.c b/usr.bin/last/last.c index e587def..945cc41 100644 --- a/usr.bin/last/last.c +++ b/usr.bin/last/last.c @@ -72,12 +72,12 @@ typedef struct arg { } ARG; static ARG *arglist; /* head of linked list */ -static LIST_HEAD(idlisthead, idtab) idlist; +static SLIST_HEAD(, idtab) idlist; struct idtab { time_t logout; /* log out time */ char id[sizeof ((struct utmpx *)0)->ut_id]; /* identifier */ - LIST_ENTRY(idtab) list; + SLIST_ENTRY(idtab) list; }; static const char *crmsg; /* cause of last reboot */ @@ -206,7 +206,7 @@ wtmp(void) char ct[80]; struct tm *tm; - LIST_INIT(&idlist); + SLIST_INIT(&idlist); (void)time(&t); /* Load the last entries from the file. */ @@ -240,16 +240,14 @@ wtmp(void) static void doentry(struct utmpx *bp) { - struct idtab *tt, *ttx; /* idlist entry */ + struct idtab *tt; /* the machine stopped */ if (bp->ut_type == BOOT_TIME || bp->ut_type == SHUTDOWN_TIME) { /* everybody just logged out */ - for (tt = LIST_FIRST(&idlist); tt;) { - LIST_REMOVE(tt, list); - ttx = tt; - tt = LIST_NEXT(tt, list); - free(ttx); + while ((tt = SLIST_FIRST(&idlist)) != NULL) { + SLIST_REMOVE_HEAD(&idlist, list); + free(tt); } currentout = -bp->ut_tv.tv_sec; crmsg = bp->ut_type != SHUTDOWN_TIME ? @@ -279,7 +277,7 @@ doentry(struct utmpx *bp) return; /* find associated identifier */ - LIST_FOREACH(tt, &idlist, list) + SLIST_FOREACH(tt, &idlist, list) if (!memcmp(tt->id, bp->ut_id, sizeof bp->ut_id)) break; @@ -290,7 +288,7 @@ doentry(struct utmpx *bp) errx(1, "malloc failure"); tt->logout = currentout; memcpy(tt->id, bp->ut_id, sizeof bp->ut_id); - LIST_INSERT_HEAD(&idlist, tt, list); + SLIST_INSERT_HEAD(&idlist, tt, list); } /* |