diff options
author | Daniel Lange <DLange@git.local> | 2020-12-07 10:26:02 +0100 |
---|---|---|
committer | Daniel Lange <DLange@git.local> | 2020-12-07 10:26:02 +0100 |
commit | d67ee86091f9e07f8d85c1fb77c7c58989e676bb (patch) | |
tree | 900f5e62bfd8e8c082be75a94f5348dea819beba /zfs/ZfsArcMeter.c | |
parent | 3cbc50cde37fee19ce98ee8260b0a6095b829c4c (diff) | |
parent | 65357c8c46154de4e4eca14075bfe5523bb5fc14 (diff) | |
download | debian_htop-d67ee86091f9e07f8d85c1fb77c7c58989e676bb.tar.gz debian_htop-d67ee86091f9e07f8d85c1fb77c7c58989e676bb.tar.bz2 debian_htop-d67ee86091f9e07f8d85c1fb77c7c58989e676bb.zip |
Update upstream source from tag 'upstream/3.0.3'
Update to upstream version '3.0.3'
with Debian dir 8a3a733dc80e45b1cde220f88fcfd815869742f0
Diffstat (limited to 'zfs/ZfsArcMeter.c')
-rw-r--r-- | zfs/ZfsArcMeter.c | 42 |
1 files changed, 16 insertions, 26 deletions
diff --git a/zfs/ZfsArcMeter.c b/zfs/ZfsArcMeter.c index 8bd0f5d..e844d77 100644 --- a/zfs/ZfsArcMeter.c +++ b/zfs/ZfsArcMeter.c @@ -1,7 +1,7 @@ /* htop - ZfsArcMeter.c (C) 2004-2011 Hisham H. Muhammad -Released under the GNU GPL, see the COPYING file +Released under the GNU GPLv2, see the COPYING file in the source distribution for its full text. */ @@ -9,25 +9,16 @@ in the source distribution for its full text. #include "ZfsArcStats.h" #include "CRT.h" +#include "Object.h" #include "Platform.h" +#include "RichString.h" -#include <stdlib.h> -#include <string.h> -#include <math.h> -#include <sys/param.h> -#include <assert.h> -/*{ -#include "ZfsArcStats.h" - -#include "Meter.h" -}*/ - -int ZfsArcMeter_attributes[] = { +static const int ZfsArcMeter_attributes[] = { ZFS_MFU, ZFS_MRU, ZFS_ANON, ZFS_HEADER, ZFS_OTHER }; -void ZfsArcMeter_readStats(Meter* this, ZfsArcStats* stats) { +void ZfsArcMeter_readStats(Meter* this, const ZfsArcStats* stats) { this->total = stats->max; this->values[0] = stats->MFU; this->values[1] = stats->MRU; @@ -38,28 +29,27 @@ void ZfsArcMeter_readStats(Meter* this, ZfsArcStats* stats) { // "Hide" the last value so it can // only be accessed by index and is not // displayed by the Bar or Graph style - Meter_setItems(this, 5); + this->curItems = 5; this->values[5] = stats->size; } -static void ZfsArcMeter_updateValues(Meter* this, char* buffer, int size) { +static void ZfsArcMeter_updateValues(Meter* this, char* buffer, size_t size) { int written; Platform_setZfsArcValues(this); written = Meter_humanUnit(buffer, this->values[5], size); - buffer += written; - if ((size -= written) > 0) { - *buffer++ = '/'; - size--; - Meter_humanUnit(buffer, this->total, size); - } + METER_BUFFER_CHECK(buffer, size, written); + + METER_BUFFER_APPEND_CHR(buffer, size, '/'); + + Meter_humanUnit(buffer, this->total, size); } -static void ZfsArcMeter_display(Object* cast, RichString* out) { - char buffer[50]; - Meter* this = (Meter*)cast; +static void ZfsArcMeter_display(const Object* cast, RichString* out) { + const Meter* this = (const Meter*)cast; if (this->values[5] > 0) { + char buffer[50]; Meter_humanUnit(buffer, this->total, 50); RichString_append(out, CRT_colors[METER_VALUE], buffer); Meter_humanUnit(buffer, this->values[5], 50); @@ -86,7 +76,7 @@ static void ZfsArcMeter_display(Object* cast, RichString* out) { } } -MeterClass ZfsArcMeter_class = { +const MeterClass ZfsArcMeter_class = { .super = { .extends = Class(Meter), .delete = Meter_delete, |