summaryrefslogtreecommitdiff
path: root/sysdeps/linux/swap.c
diff options
context:
space:
mode:
authorMartin Baulig <martin@src.gnome.org>1998-06-07 21:14:30 +0000
committerMartin Baulig <martin@src.gnome.org>1998-06-07 21:14:30 +0000
commitbe91463190323d9208bb64c682f8e3867dc81ff7 (patch)
tree6620c08d10d73af2faf7681602858708dcbbdb2e /sysdeps/linux/swap.c
parent28324c38cc08f5b9b9c05160800298cba49022df (diff)
downloadlibgtop-be91463190323d9208bb64c682f8e3867dc81ff7.tar.gz
More profiling stuff.
Diffstat (limited to 'sysdeps/linux/swap.c')
-rw-r--r--sysdeps/linux/swap.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/sysdeps/linux/swap.c b/sysdeps/linux/swap.c
index fd8b29f7..24d44c06 100644
--- a/sysdeps/linux/swap.c
+++ b/sysdeps/linux/swap.c
@@ -34,7 +34,7 @@ static unsigned long _glibtop_sysdeps_swap =
void
glibtop_get_swap_s (glibtop *server, glibtop_swap *buf)
{
- char buffer [BUFSIZ];
+ char buffer [BUFSIZ], *tmp;
int fd = 0, ret;
glibtop_init_r (&server, 0, 0);
@@ -60,8 +60,13 @@ glibtop_get_swap_s (glibtop *server, glibtop_swap *buf)
glibtop_error_r (server, "read (%s): %s",
FILENAME, strerror (errno));
- sscanf (buffer, "%*[^\n]\n%*[^\n]\nSwap: %lu %lu %lu\n",
- &buf->total, &buf->used, &buf->free);
+ tmp = strchr (buffer, '\n');
+ tmp = strchr (tmp+1, '\n');
+
+ tmp = skip_token (tmp); /* "Swap:" */
+ buf->total = strtoul (tmp, &tmp, 10);
+ buf->used = strtoul (tmp, &tmp, 10);
+ buf->free = strtoul (tmp, &tmp, 10);
#ifdef GLIBTOP_CACHE_OPEN
server->machine.fd_meminfo = fd;