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.
This commit is contained in:
Benoît Dejean
2004-05-25 14:33:46 +00:00
parent f070fea744
commit 0de7c96d2a
5 changed files with 46 additions and 40 deletions

View File

@@ -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;