summaryrefslogtreecommitdiffstats
path: root/MemoryMeter.c
diff options
context:
space:
mode:
authorGuillaume Gomez <guillaume1.gomez@gmail.com>2023-01-07 17:46:15 +0100
committerBenBE <BenBE@geshi.org>2023-01-07 19:30:23 +0100
commit560a04ad25c77a8c5bf4cec112a3d8da8df6272c (patch)
tree76bd2534fc2dae7c03bcd6fbbd815f21677e37df /MemoryMeter.c
parent29f0b3c5e1184421ee7796ab2e1841733c45f403 (diff)
Improve code readability by creating constants for memory values
Diffstat (limited to 'MemoryMeter.c')
-rw-r--r--MemoryMeter.c20
1 files changed, 10 insertions, 10 deletions
diff --git a/MemoryMeter.c b/MemoryMeter.c
index 89e242ca..ac01dfe7 100644
--- a/MemoryMeter.c
+++ b/MemoryMeter.c
@@ -29,14 +29,14 @@ static void MemoryMeter_updateValues(Meter* this) {
int written;
/* shared and available memory are not supported on all platforms */
- this->values[2] = NAN;
- this->values[4] = NAN;
+ this->values[MEMORY_METER_SHARED] = NAN;
+ this->values[MEMORY_METER_AVAILABLE] = NAN;
Platform_setMemoryValues(this);
/* Do not print available memory in bar mode */
this->curItems = 4;
- written = Meter_humanUnit(buffer, this->values[0], size);
+ written = Meter_humanUnit(buffer, this->values[MEMORY_METER_USED], size);
METER_BUFFER_CHECK(buffer, size, written);
METER_BUFFER_APPEND_CHR(buffer, size, '/');
@@ -52,28 +52,28 @@ static void MemoryMeter_display(const Object* cast, RichString* out) {
Meter_humanUnit(buffer, this->total, sizeof(buffer));
RichString_appendAscii(out, CRT_colors[METER_VALUE], buffer);
- Meter_humanUnit(buffer, this->values[0], sizeof(buffer));
+ Meter_humanUnit(buffer, this->values[MEMORY_METER_USED], sizeof(buffer));
RichString_appendAscii(out, CRT_colors[METER_TEXT], " used:");
RichString_appendAscii(out, CRT_colors[MEMORY_USED], buffer);
- Meter_humanUnit(buffer, this->values[1], sizeof(buffer));
+ Meter_humanUnit(buffer, this->values[MEMORY_METER_BUFFERS], sizeof(buffer));
RichString_appendAscii(out, CRT_colors[METER_TEXT], " buffers:");
RichString_appendAscii(out, CRT_colors[MEMORY_BUFFERS_TEXT], buffer);
/* shared memory is not supported on all platforms */
- if (!isnan(this->values[2])) {
- Meter_humanUnit(buffer, this->values[2], sizeof(buffer));
+ if (!isnan(this->values[MEMORY_METER_SHARED])) {
+ Meter_humanUnit(buffer, this->values[MEMORY_METER_SHARED], sizeof(buffer));
RichString_appendAscii(out, CRT_colors[METER_TEXT], " shared:");
RichString_appendAscii(out, CRT_colors[MEMORY_SHARED], buffer);
}
- Meter_humanUnit(buffer, this->values[3], sizeof(buffer));
+ Meter_humanUnit(buffer, this->values[MEMORY_METER_CACHE], sizeof(buffer));
RichString_appendAscii(out, CRT_colors[METER_TEXT], " cache:");
RichString_appendAscii(out, CRT_colors[MEMORY_CACHE], buffer);
/* available memory is not supported on all platforms */
- if (!isnan(this->values[4])) {
- Meter_humanUnit(buffer, this->values[4], sizeof(buffer));
+ if (!isnan(this->values[MEMORY_METER_AVAILABLE])) {
+ Meter_humanUnit(buffer, this->values[MEMORY_METER_AVAILABLE], sizeof(buffer));
RichString_appendAscii(out, CRT_colors[METER_TEXT], " available:");
RichString_appendAscii(out, CRT_colors[METER_VALUE], buffer);
}

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