diff options
author | Explorer09 <explorer09@gmail.com> | 2024-04-16 20:18:08 +0800 |
---|---|---|
committer | BenBE <BenBE@geshi.org> | 2024-04-20 19:36:00 +0200 |
commit | c711dbc6335869cedfb4fb0c09d71985dd0423c1 (patch) | |
tree | 2adc615727278d2972a4f98346653deef6fb1ede | |
parent | 2fa283d202a47c52dac60e67c907a1f5a7f98870 (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.c | 4 |
1 files changed, 3 insertions, 1 deletions
@@ -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); } |