aboutsummaryrefslogtreecommitdiffstats
path: root/LoadAverageMeter.c
diff options
context:
space:
mode:
authorDaniel Lange <DLange@git.local>2020-12-07 10:26:01 +0100
committerDaniel Lange <DLange@git.local>2020-12-07 10:26:01 +0100
commit65357c8c46154de4e4eca14075bfe5523bb5fc14 (patch)
tree8f430ee5a0d5de377c4e7c94e47842a27c70d7e8 /LoadAverageMeter.c
parentf80394a20254938142011855f2954b3f63fe5909 (diff)
downloaddebian_htop-65357c8c46154de4e4eca14075bfe5523bb5fc14.tar.gz
debian_htop-65357c8c46154de4e4eca14075bfe5523bb5fc14.tar.bz2
debian_htop-65357c8c46154de4e4eca14075bfe5523bb5fc14.zip
New upstream version 3.0.3upstream/3.0.3
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