Released 2.20.2

svn path=/branches/gnome-2-20/; revision=2721
This commit is contained in:
Benoît Dejean
2008-03-07 18:14:47 +00:00
parent 40f849475b
commit a33e785484
4 changed files with 103 additions and 50 deletions

View File

@@ -17,27 +17,31 @@
unsigned long long
get_scaled(const char *buffer, const char *key)
{
const char *ptr;
const char *ptr = buffer;;
char *next;
unsigned long long value = 0;
unsigned long long value;
if (G_LIKELY((ptr = strstr(buffer, key))))
{
ptr += strlen(key);
value = strtoull(ptr, &next, 0);
for ( ; *next; ++next) {
if (*next == 'k') {
value *= 1024;
break;
} else if (*next == 'M') {
value *= 1024 * 1024;
break;
}
if (key) {
if (G_LIKELY((ptr = strstr(buffer, key))))
ptr += strlen(key);
else {
g_warning("Could not read key '%s' in buffer '%s'",
key, buffer);
return 0;
}
} else
g_warning("Could not read key '%s' in buffer '%s'",
key, buffer);
}
value = strtoull(ptr, &next, 0);
for ( ; *next; ++next) {
if (*next == 'k') {
value *= 1024;
break;
} else if (*next == 'M') {
value *= 1024 * 1024;
break;
}
}
return value;
}