From 65357c8c46154de4e4eca14075bfe5523bb5fc14 Mon Sep 17 00:00:00 2001 From: Daniel Lange Date: Mon, 7 Dec 2020 10:26:01 +0100 Subject: New upstream version 3.0.3 --- SwapMeter.c | 31 +++++++++++++------------------ 1 file changed, 13 insertions(+), 18 deletions(-) (limited to 'SwapMeter.c') 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 -#include -#include -#include -#include - -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, -- cgit v1.2.3