aboutsummaryrefslogtreecommitdiffstats
path: root/SwapMeter.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 /SwapMeter.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 'SwapMeter.c')
-rw-r--r--SwapMeter.c31
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,

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