aboutsummaryrefslogtreecommitdiffstats
path: root/LoadAverageMeter.c
diff options
context:
space:
mode:
authorDaniel Lange <DLange@git.local>2020-12-07 10:26:02 +0100
committerDaniel Lange <DLange@git.local>2020-12-07 10:26:02 +0100
commitd67ee86091f9e07f8d85c1fb77c7c58989e676bb (patch)
tree900f5e62bfd8e8c082be75a94f5348dea819beba /LoadAverageMeter.c
parent3cbc50cde37fee19ce98ee8260b0a6095b829c4c (diff)
parent65357c8c46154de4e4eca14075bfe5523bb5fc14 (diff)
downloaddebian_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 'LoadAverageMeter.c')
-rw-r--r--LoadAverageMeter.c33
1 files changed, 20 insertions, 13 deletions
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,

© 2014-2024 Faster IT GmbH | imprint | privacy policy