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 /SwapMeter.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 'SwapMeter.c')
-rw-r--r-- | SwapMeter.c | 31 |
1 files changed, 13 insertions, 18 deletions
diff --git a/SwapMeter.c b/SwapMeter.c index fcf450e..8e39c75 100644 --- a/SwapMeter.c +++ b/SwapMeter.c @@ -1,42 +1,37 @@ /* htop - SwapMeter.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. */ #include "SwapMeter.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> - -int SwapMeter_attributes[] = { +static const int SwapMeter_attributes[] = { SWAP }; -static void SwapMeter_updateValues(Meter* this, char* buffer, int size) { +static void SwapMeter_updateValues(Meter* this, char* buffer, size_t size) { int written; Platform_setSwapValues(this); written = Meter_humanUnit(buffer, this->values[0], 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 SwapMeter_display(Object* cast, RichString* out) { +static void SwapMeter_display(const Object* cast, RichString* out) { char buffer[50]; - Meter* this = (Meter*)cast; + const Meter* this = (const Meter*)cast; RichString_write(out, CRT_colors[METER_TEXT], ":"); Meter_humanUnit(buffer, this->total, 50); RichString_append(out, CRT_colors[METER_VALUE], buffer); @@ -45,7 +40,7 @@ static void SwapMeter_display(Object* cast, RichString* out) { RichString_append(out, CRT_colors[METER_VALUE], buffer); } -MeterClass SwapMeter_class = { +const MeterClass SwapMeter_class = { .super = { .extends = Class(Meter), .delete = Meter_delete, |