diff options
author | Daniel Lange <DLange@git.local> | 2024-01-10 12:40:37 +0100 |
---|---|---|
committer | Daniel Lange <DLange@git.local> | 2024-01-10 12:40:37 +0100 |
commit | 7271b076b82785ffca73ee9e4ae84cabb77018ee (patch) | |
tree | e8270dd60ec096bee8157dbadf029e15ed584592 /linux/ZramMeter.c | |
parent | f288666edc9180a2e81e6655951878124f321df6 (diff) | |
download | debian_htop-7271b076b82785ffca73ee9e4ae84cabb77018ee.tar.gz debian_htop-7271b076b82785ffca73ee9e4ae84cabb77018ee.tar.bz2 debian_htop-7271b076b82785ffca73ee9e4ae84cabb77018ee.zip |
New upstream version 3.3.0upstream/3.3.0upstream
Diffstat (limited to 'linux/ZramMeter.c')
-rw-r--r-- | linux/ZramMeter.c | 31 |
1 files changed, 21 insertions, 10 deletions
diff --git a/linux/ZramMeter.c b/linux/ZramMeter.c index e1e27b7..8329f01 100644 --- a/linux/ZramMeter.c +++ b/linux/ZramMeter.c @@ -1,3 +1,13 @@ +/* +htop - linux/ZramMeter.c +(C) 2020 Murloc Knight +(C) 2020-2023 htop dev team +Released under the GNU GPLv2+, see the COPYING file +in the source distribution for its full text. +*/ + +#include "config.h" // IWYU pragma: keep + #include "linux/ZramMeter.h" #include <stddef.h> @@ -7,10 +17,12 @@ #include "Object.h" #include "Platform.h" #include "RichString.h" +#include "ZramMeter.h" -static const int ZramMeter_attributes[] = { - ZRAM +static const int ZramMeter_attributes[ZRAM_METER_ITEMCOUNT] = { + [ZRAM_METER_COMPRESSED] = ZRAM_COMPRESSED, + [ZRAM_METER_UNCOMPRESSED] = ZRAM_UNCOMPRESSED, }; static void ZramMeter_updateValues(Meter* this) { @@ -20,15 +32,13 @@ static void ZramMeter_updateValues(Meter* this) { Platform_setZramValues(this); - /* on print bar for compressed data size, not uncompressed */ - this->curItems = 1; - - written = Meter_humanUnit(buffer, this->values[0], size); + written = Meter_humanUnit(buffer, this->values[ZRAM_METER_COMPRESSED], size); METER_BUFFER_CHECK(buffer, size, written); METER_BUFFER_APPEND_CHR(buffer, size, '('); - written = Meter_humanUnit(buffer, this->values[1], size); + double uncompressed = this->values[ZRAM_METER_COMPRESSED] + this->values[ZRAM_METER_UNCOMPRESSED]; + written = Meter_humanUnit(buffer, uncompressed, size); METER_BUFFER_CHECK(buffer, size, written); METER_BUFFER_APPEND_CHR(buffer, size, ')'); @@ -47,11 +57,12 @@ static void ZramMeter_display(const Object* cast, RichString* out) { 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[ZRAM_METER_COMPRESSED], sizeof(buffer)); RichString_appendAscii(out, CRT_colors[METER_TEXT], " used:"); RichString_appendAscii(out, CRT_colors[METER_VALUE], buffer); - Meter_humanUnit(buffer, this->values[1], sizeof(buffer)); + double uncompressed = this->values[ZRAM_METER_COMPRESSED] + this->values[ZRAM_METER_UNCOMPRESSED]; + Meter_humanUnit(buffer, uncompressed, sizeof(buffer)); RichString_appendAscii(out, CRT_colors[METER_TEXT], " uncompressed:"); RichString_appendAscii(out, CRT_colors[METER_VALUE], buffer); } @@ -64,7 +75,7 @@ const MeterClass ZramMeter_class = { }, .updateValues = ZramMeter_updateValues, .defaultMode = BAR_METERMODE, - .maxItems = 2, + .maxItems = ZRAM_METER_ITEMCOUNT, .total = 100.0, .attributes = ZramMeter_attributes, .name = "Zram", |