diff options
author | Benoît Dejean <bdejean@src.gnome.org> | 2004-05-25 14:33:46 +0000 |
---|---|---|
committer | Benoît Dejean <bdejean@src.gnome.org> | 2004-05-25 14:33:46 +0000 |
commit | 0de7c96d2abe488914243f1fd35b6eae1ad5d1ab (patch) | |
tree | 4e5698743ba3c06f0484fb8c57554aba01fd6836 /sysdeps/linux/glibtop_server.h | |
parent | f070fea7440be872c33c6a6234bd305b03e93c0a (diff) | |
download | libgtop-0de7c96d2abe488914243f1fd35b6eae1ad5d1ab.tar.gz |
Added test for end of string. (get_scaled): Cleaned.
* glibtop_server.h (skip_line): Added test for end of string.
(get_scaled): Cleaned.
* cpu.c (glibtop_get_cpu_s):
* open.c (glibtop_open_s): Fixed SMP detection. Closes #142597.
* uptime.c (glibtop_get_uptime_s): Added boot_time.
Diffstat (limited to 'sysdeps/linux/glibtop_server.h')
-rw-r--r-- | sysdeps/linux/glibtop_server.h | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/sysdeps/linux/glibtop_server.h b/sysdeps/linux/glibtop_server.h index 22060a3f..d96bbb33 100644 --- a/sysdeps/linux/glibtop_server.h +++ b/sysdeps/linux/glibtop_server.h @@ -53,8 +53,8 @@ skip_multiple_token (const char *p, int count) static inline char * skip_line (const char *p) { - while (*p != '\n') p++; - return (char *) ++p; + while (*p && *p != '\n') p++; + return (char *) (*p ? p+1 : p); } static inline unsigned long long @@ -62,11 +62,12 @@ get_scaled(const char *buffer, const char *key) { const char *ptr; char *next; + const size_t len = strlen(key); unsigned long long value = 0; if ((ptr = strstr(buffer, key))) { - ptr += strlen(key); + ptr += len; value = strtoull(ptr, &next, 0); if (strchr(next, 'k')) value *= 1024; |