summaryrefslogtreecommitdiffstats
path: root/SwapMeter.c
diff options
context:
space:
mode:
authorChristian Hesse <mail@eworm.de>2015-06-12 09:50:55 +0200
committerChristian Hesse <mail@eworm.de>2015-08-27 06:13:27 +0200
commit6f58fbc5dd091557129895bbd0a05335e411d19e (patch)
tree8c9b67ce97072ab0d53d1c2552994a60eb672984 /SwapMeter.c
parentf3a9f5406beb52da58432fdc30eb9db233cff390 (diff)
make units more dynamic
Signed-off-by: Christian Hesse <mail@eworm.de>
Diffstat (limited to 'SwapMeter.c')
-rw-r--r--SwapMeter.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/SwapMeter.c b/SwapMeter.c
index a19c0300..aaa5e93c 100644
--- a/SwapMeter.c
+++ b/SwapMeter.c
@@ -33,9 +33,17 @@ static void SwapMeter_humanNumber(char* buffer, const long int* value) {
sprintf(buffer, "%ldM ", *value / MEGABYTE);
}
-static void SwapMeter_setValues(Meter* this, char* buffer, int len) {
+static void SwapMeter_setValues(Meter* this, char* buffer, int size) {
+ int written;
Platform_setSwapValues(this);
- snprintf(buffer, len, "%ld/%ldM", (long int) this->values[0] / MEGABYTE, (long int) this->total / MEGABYTE);
+
+ written = Meter_humanUnit(buffer, this->values[0], size);
+ buffer += written;
+ if ((size -= written) > 0) {
+ *buffer++ = '/';
+ size--;
+ Meter_humanUnit(buffer, this->total, size);
+ }
}
static void SwapMeter_display(Object* cast, RichString* out) {

© 2014-2024 Faster IT GmbH | imprint | privacy policy