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 --- LoadAverageMeter.c | 33 ++++++++++++++++++++------------- 1 file changed, 20 insertions(+), 13 deletions(-) (limited to 'LoadAverageMeter.c') diff --git a/LoadAverageMeter.c b/LoadAverageMeter.c index db397b6..d5424cd 100644 --- a/LoadAverageMeter.c +++ b/LoadAverageMeter.c @@ -1,29 +1,36 @@ /* htop - LoadAverageMeter.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 "LoadAverageMeter.h" #include "CRT.h" +#include "Object.h" #include "Platform.h" +#include "RichString.h" +#include "XUtils.h" -int LoadAverageMeter_attributes[] = { - LOAD_AVERAGE_ONE, LOAD_AVERAGE_FIVE, LOAD_AVERAGE_FIFTEEN +static const int LoadAverageMeter_attributes[] = { + LOAD_AVERAGE_ONE, + LOAD_AVERAGE_FIVE, + LOAD_AVERAGE_FIFTEEN }; -int LoadMeter_attributes[] = { LOAD }; +static const int LoadMeter_attributes[] = { + LOAD +}; -static void LoadAverageMeter_updateValues(Meter* this, char* buffer, int size) { +static void LoadAverageMeter_updateValues(Meter* this, char* buffer, size_t size) { Platform_getLoadAverage(&this->values[0], &this->values[1], &this->values[2]); xSnprintf(buffer, size, "%.2f/%.2f/%.2f", this->values[0], this->values[1], this->values[2]); } -static void LoadAverageMeter_display(Object* cast, RichString* out) { - Meter* this = (Meter*)cast; +static void LoadAverageMeter_display(const Object* cast, RichString* out) { + const Meter* this = (const Meter*)cast; char buffer[20]; xSnprintf(buffer, sizeof(buffer), "%.2f ", this->values[0]); RichString_write(out, CRT_colors[LOAD_AVERAGE_ONE], buffer); @@ -33,7 +40,7 @@ static void LoadAverageMeter_display(Object* cast, RichString* out) { RichString_append(out, CRT_colors[LOAD_AVERAGE_FIFTEEN], buffer); } -static void LoadMeter_updateValues(Meter* this, char* buffer, int size) { +static void LoadMeter_updateValues(Meter* this, char* buffer, size_t size) { double five, fifteen; Platform_getLoadAverage(&this->values[0], &five, &fifteen); if (this->values[0] > this->total) { @@ -42,14 +49,14 @@ static void LoadMeter_updateValues(Meter* this, char* buffer, int size) { xSnprintf(buffer, size, "%.2f", this->values[0]); } -static void LoadMeter_display(Object* cast, RichString* out) { - Meter* this = (Meter*)cast; +static void LoadMeter_display(const Object* cast, RichString* out) { + const Meter* this = (const Meter*)cast; char buffer[20]; - xSnprintf(buffer, sizeof(buffer), "%.2f ", ((Meter*)this)->values[0]); + xSnprintf(buffer, sizeof(buffer), "%.2f ", this->values[0]); RichString_write(out, CRT_colors[LOAD], buffer); } -MeterClass LoadAverageMeter_class = { +const MeterClass LoadAverageMeter_class = { .super = { .extends = Class(Meter), .delete = Meter_delete, @@ -66,7 +73,7 @@ MeterClass LoadAverageMeter_class = { .caption = "Load average: " }; -MeterClass LoadMeter_class = { +const MeterClass LoadMeter_class = { .super = { .extends = Class(Meter), .delete = Meter_delete, -- cgit v1.2.3