aboutsummaryrefslogtreecommitdiffstats
path: root/SwapMeter.c
diff options
context:
space:
mode:
authorDaniel Lange <DLange@git.local>2016-04-11 13:01:07 +0200
committerDaniel Lange <DLange@git.local>2016-04-11 13:01:07 +0200
commitff9409b1737627857eb47f64f536a3f66b6a09a4 (patch)
tree61b631ba551e68a4f656b8b76ff7bd0d9955fc64 /SwapMeter.c
parentf75ab6d2c11e8a8e18191b087564aedebbeb96c5 (diff)
downloaddebian_htop-ff9409b1737627857eb47f64f536a3f66b6a09a4.tar.gz
debian_htop-ff9409b1737627857eb47f64f536a3f66b6a09a4.tar.bz2
debian_htop-ff9409b1737627857eb47f64f536a3f66b6a09a4.zip
Imported Upstream version 2.0.0upstream/2.0.0
Diffstat (limited to 'SwapMeter.c')
-rw-r--r--SwapMeter.c34
1 files changed, 14 insertions, 20 deletions
diff --git a/SwapMeter.c b/SwapMeter.c
index 2cb86d5..895ca0b 100644
--- a/SwapMeter.c
+++ b/SwapMeter.c
@@ -8,7 +8,7 @@ in the source distribution for its full text.
#include "SwapMeter.h"
#include "CRT.h"
-#include "ProcessList.h"
+#include "Platform.h"
#include <stdlib.h>
#include <string.h>
@@ -20,37 +20,31 @@ in the source distribution for its full text.
#include "Meter.h"
}*/
-#define KILOBYTE 1
-#define MEGABYTE 1024
-#define GIGABYTE 1048576
-
int SwapMeter_attributes[] = {
SWAP
};
-/* NOTE: Value is in kilobytes */
-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) {
- long int usedSwap = this->pl->usedSwap;
- this->total = this->pl->totalSwap;
- this->values[0] = usedSwap;
+static void SwapMeter_setValues(Meter* this, char* buffer, int size) {
+ int written;
+ Platform_setSwapValues(this);
- snprintf(buffer, len, "%ld/%ldMB", (long int) usedSwap / 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) {
char buffer[50];
Meter* this = (Meter*)cast;
- long int swap = (long int) this->values[0];
- long int total = (long int) this->total;
RichString_write(out, CRT_colors[METER_TEXT], ":");
- SwapMeter_humanNumber(buffer, &total);
+ Meter_humanUnit(buffer, this->total, 50);
RichString_append(out, CRT_colors[METER_VALUE], buffer);
- SwapMeter_humanNumber(buffer, &swap);
- RichString_append(out, CRT_colors[METER_TEXT], "used:");
+ Meter_humanUnit(buffer, this->values[0], 50);
+ RichString_append(out, CRT_colors[METER_TEXT], " used:");
RichString_append(out, CRT_colors[METER_VALUE], buffer);
}

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