summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorExplorer09 <explorer09@gmail.com>2024-04-16 20:18:08 +0800
committerBenBE <BenBE@geshi.org>2024-04-20 19:36:00 +0200
commitc711dbc6335869cedfb4fb0c09d71985dd0423c1 (patch)
tree2adc615727278d2972a4f98346653deef6fb1ede
parent2fa283d202a47c52dac60e67c907a1f5a7f98870 (diff)
CPUMeter: Read height from sub-meter objects
The Meter objects have their own 'h' properties. Avoid access to the `Meter_modes` array. Signed-off-by: Kang-Che Sung <explorer09@gmail.com>
-rw-r--r--CPUMeter.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/CPUMeter.c b/CPUMeter.c
index 2f777b2e..58f4455d 100644
--- a/CPUMeter.c
+++ b/CPUMeter.c
@@ -9,6 +9,7 @@ in the source distribution for its full text.
#include "CPUMeter.h"
+#include <assert.h>
#include <stdbool.h>
#include <stddef.h>
#include <stdlib.h>
@@ -256,12 +257,13 @@ static void CPUMeterCommonUpdateMode(Meter* this, int mode, int ncol) {
CPUMeterData* data = this->meterData;
Meter** meters = data->meters;
this->mode = mode;
- int h = Meter_modes[mode]->h;
int start, count;
AllCPUsMeter_getRange(this, &start, &count);
for (int i = 0; i < count; i++) {
Meter_setMode(meters[i], mode);
}
+ int h = meters[0]->h;
+ assert(h > 0);
this->h = h * ((count + ncol - 1) / ncol);
}

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