aboutsummaryrefslogtreecommitdiff
path: root/toys/pending/last.c
diff options
context:
space:
mode:
authorRob Landley <rob@landley.net>2014-05-21 07:01:16 -0500
committerRob Landley <rob@landley.net>2014-05-21 07:01:16 -0500
commit7a6b82277db3caee1214cdbc8f6bc546818aec6e (patch)
treeb3bfeb73a941a36149462ed4e6fdc8342ea20922 /toys/pending/last.c
parente604d5344466df8584c48c8492397fcffa63a671 (diff)
downloadtoybox-7a6b82277db3caee1214cdbc8f6bc546818aec6e.tar.gz
Make last use common llist free function, minor cleanups.
Diffstat (limited to 'toys/pending/last.c')
-rw-r--r--toys/pending/last.c18
1 files changed, 6 insertions, 12 deletions
diff --git a/toys/pending/last.c b/toys/pending/last.c
index 53a9ee05..223082f2 100644
--- a/toys/pending/last.c
+++ b/toys/pending/last.c
@@ -33,18 +33,10 @@ GLOBALS(
struct arg_list *list;
)
-static void free_node(void *data)
-{
- void *arg = ((struct arg_list*)data)->arg;
-
- if (arg) free(arg);
- free(data);
-}
-
static void free_list()
{
if (TT.list) {
- llist_traverse(TT.list, free_node);
+ llist_traverse(TT.list, free_arg_list);
TT.list = NULL;
}
}
@@ -113,6 +105,7 @@ void last_main(void)
if(loc < 0) break;
xlseek(fd, loc, SEEK_SET);
+ // Read next structure, determine type
xreadall(fd, &ut, sizeof(ut));
*tm = ut.ut_tv.tv_sec;
if (*ut.ut_line == '~') {
@@ -194,9 +187,10 @@ void last_main(void)
xlseek(fd, loc, SEEK_SET);
}
- xclose(fd);
-
- if (CFG_TOYBOX_FREE) free_list();
+ if (CFG_TOYBOX_FREE) {
+ xclose(fd);
+ free_list();
+ }
xprintf("\n%s begins %-24.24s\n", basename(file), ctime(tm));
}