diff options
author | Benoît Dejean <bdejean@src.gnome.org> | 2005-07-07 19:34:18 +0000 |
---|---|---|
committer | Benoît Dejean <bdejean@src.gnome.org> | 2005-07-07 19:34:18 +0000 |
commit | 16e0c943b233589eae09b8307099a17b0c642997 (patch) | |
tree | bda4febe5d680c94426feac748823e513b8a3a25 | |
parent | f409c553f59cf4ba4542d29f7f50e8c0463923c8 (diff) | |
download | libgtop-16e0c943b233589eae09b8307099a17b0c642997.tar.gz |
Cached boot_time.
* glibtop_private.c: (read_boot_time), (get_boot_time): Cached boot_time.
-rw-r--r-- | sysdeps/linux/ChangeLog | 4 | ||||
-rw-r--r-- | sysdeps/linux/glibtop_private.c | 20 |
2 files changed, 22 insertions, 2 deletions
diff --git a/sysdeps/linux/ChangeLog b/sysdeps/linux/ChangeLog index 00eec6e1..605ab882 100644 --- a/sysdeps/linux/ChangeLog +++ b/sysdeps/linux/ChangeLog @@ -1,3 +1,7 @@ +2005-07-07 Benoît Dejean <TazForEver@dlfp.org> + + * glibtop_private.c: (read_boot_time), (get_boot_time): Cached boot_time. + 2005-07-06 Benoît Dejean <TazForEver@dlfp.org> Et m***e ... CVS got me. I wanted to commit a single change on the diff --git a/sysdeps/linux/glibtop_private.c b/sysdeps/linux/glibtop_private.c index 32d7462b..645b14c3 100644 --- a/sysdeps/linux/glibtop_private.c +++ b/sysdeps/linux/glibtop_private.c @@ -98,8 +98,8 @@ file_to_buffer(glibtop *server, char *buffer, const char *filename) -unsigned long -get_boot_time(glibtop *server) +static unsigned long +read_boot_time(glibtop *server) { char buffer[BUFSIZ]; char *btime; @@ -113,3 +113,19 @@ get_boot_time(glibtop *server) btime = skip_token(btime); return strtoul(btime, NULL, 10); } + + + +unsigned long +get_boot_time(glibtop *server) +{ + static unsigned long boot_time = 0UL; + + if(G_UNLIKELY(!boot_time)) + { + boot_time = read_boot_time(server); + } + + return boot_time; +} + |