diff options
author | Daniel Lange <DLange@git.local> | 2024-01-10 11:17:08 +0100 |
---|---|---|
committer | Daniel Lange <DLange@git.local> | 2024-01-10 11:17:08 +0100 |
commit | e7372d18a1a661d8c3dba9f51e1f17b5f94171a7 (patch) | |
tree | e8270dd60ec096bee8157dbadf029e15ed584592 /SwapMeter.c | |
parent | 937052b231259a47d881d539ad5748245ef55b99 (diff) | |
download | debian_htop-e7372d18a1a661d8c3dba9f51e1f17b5f94171a7.tar.gz debian_htop-e7372d18a1a661d8c3dba9f51e1f17b5f94171a7.tar.bz2 debian_htop-e7372d18a1a661d8c3dba9f51e1f17b5f94171a7.zip |
New upstream version 3.3.0
Diffstat (limited to 'SwapMeter.c')
-rw-r--r-- | SwapMeter.c | 23 |
1 files changed, 16 insertions, 7 deletions
diff --git a/SwapMeter.c b/SwapMeter.c index 081967f..1055a6e 100644 --- a/SwapMeter.c +++ b/SwapMeter.c @@ -13,6 +13,7 @@ in the source distribution for its full text. #include <stddef.h> #include "CRT.h" +#include "Macros.h" #include "Object.h" #include "Platform.h" #include "RichString.h" @@ -20,7 +21,8 @@ in the source distribution for its full text. static const int SwapMeter_attributes[] = { SWAP, - SWAP_CACHE + SWAP_CACHE, + SWAP_FRONTSWAP, }; static void SwapMeter_updateValues(Meter* this) { @@ -28,10 +30,11 @@ static void SwapMeter_updateValues(Meter* this) { size_t size = sizeof(this->txtBuffer); int written; - this->values[1] = NAN; /* 'cached' not present on all platforms */ + this->values[SWAP_METER_CACHE] = NAN; /* 'cached' not present on all platforms */ + this->values[SWAP_METER_FRONTSWAP] = NAN; /* 'frontswap' not present on all platforms */ Platform_setSwapValues(this); - written = Meter_humanUnit(buffer, this->values[0], size); + written = Meter_humanUnit(buffer, this->values[SWAP_METER_USED], size); METER_BUFFER_CHECK(buffer, size, written); METER_BUFFER_APPEND_CHR(buffer, size, '/'); @@ -45,15 +48,21 @@ static void SwapMeter_display(const Object* cast, RichString* out) { RichString_writeAscii(out, CRT_colors[METER_TEXT], ":"); Meter_humanUnit(buffer, this->total, sizeof(buffer)); RichString_appendAscii(out, CRT_colors[METER_VALUE], buffer); - Meter_humanUnit(buffer, this->values[0], sizeof(buffer)); + Meter_humanUnit(buffer, this->values[SWAP_METER_USED], sizeof(buffer)); RichString_appendAscii(out, CRT_colors[METER_TEXT], " used:"); RichString_appendAscii(out, CRT_colors[METER_VALUE], buffer); - if (!isnan(this->values[1])) { - Meter_humanUnit(buffer, this->values[1], sizeof(buffer)); + if (isNonnegative(this->values[SWAP_METER_CACHE])) { + Meter_humanUnit(buffer, this->values[SWAP_METER_CACHE], sizeof(buffer)); RichString_appendAscii(out, CRT_colors[METER_TEXT], " cache:"); RichString_appendAscii(out, CRT_colors[SWAP_CACHE], buffer); } + + if (isNonnegative(this->values[SWAP_METER_FRONTSWAP])) { + Meter_humanUnit(buffer, this->values[SWAP_METER_FRONTSWAP], sizeof(buffer)); + RichString_appendAscii(out, CRT_colors[METER_TEXT], " frontswap:"); + RichString_appendAscii(out, CRT_colors[SWAP_FRONTSWAP], buffer); + } } const MeterClass SwapMeter_class = { @@ -64,7 +73,7 @@ const MeterClass SwapMeter_class = { }, .updateValues = SwapMeter_updateValues, .defaultMode = BAR_METERMODE, - .maxItems = 2, + .maxItems = SWAP_METER_ITEMCOUNT, .total = 100.0, .attributes = SwapMeter_attributes, .name = "Swap", |