diff --git a/sysdeps/linux/ChangeLog b/sysdeps/linux/ChangeLog index 90927f2d..1f06d345 100644 --- a/sysdeps/linux/ChangeLog +++ b/sysdeps/linux/ChangeLog @@ -1,3 +1,9 @@ +2007-01-11 Benoît Dejean + + * glibtop_private.c: (get_scaled): + + Replaced two strstr by a hand-written loop in this critical code. + 2006-09-11 Benoît Dejean * procmap.c: (glibtop_get_proc_map_s): diff --git a/sysdeps/linux/glibtop_private.c b/sysdeps/linux/glibtop_private.c index 490e1728..e93f8397 100644 --- a/sysdeps/linux/glibtop_private.c +++ b/sysdeps/linux/glibtop_private.c @@ -25,10 +25,16 @@ get_scaled(const char *buffer, const char *key) { ptr += strlen(key); value = strtoull(ptr, &next, 0); - if (strchr(next, 'k')) - value *= 1024; - else if (strchr(next, 'M')) - value *= 1024 * 1024; + + for ( ; *next; ++next) { + if (*next == 'k') { + value *= 1024; + break; + } else if (*next == 'M') { + value *= 1024 * 1024; + break; + } + } } else g_warning("Could not read key '%s' in buffer '%s'", key, buffer);