mirror of https://github.com/xzeldon/htop.git
Use integer type for item count instead of char
This commit is contained in:
parent
59ef15b2ad
commit
43d274a617
|
@ -51,8 +51,7 @@ static void CPUMeter_updateValues(Meter* this, char* buffer, int size) {
|
|||
int cpu = this->param;
|
||||
if (cpu > this->pl->cpuCount) {
|
||||
xSnprintf(buffer, size, "absent");
|
||||
int items = this->curItems;
|
||||
for (int i = 0; i < items; i++)
|
||||
for (uint8_t i = 0; i < this->curItems; i++)
|
||||
this->values[i] = 0;
|
||||
return;
|
||||
}
|
||||
|
|
8
Meter.c
8
Meter.c
|
@ -195,8 +195,7 @@ static void BarMeterMode_draw(Meter* this, int x, int y, int w) {
|
|||
|
||||
// First draw in the bar[] buffer...
|
||||
int offset = 0;
|
||||
int items = this->curItems;
|
||||
for (int i = 0; i < items; i++) {
|
||||
for (uint8_t i = 0; i < this->curItems; i++) {
|
||||
double value = this->values[i];
|
||||
value = CLAMP(value, 0.0, this->total);
|
||||
if (value > 0) {
|
||||
|
@ -220,7 +219,7 @@ static void BarMeterMode_draw(Meter* this, int x, int y, int w) {
|
|||
|
||||
// ...then print the buffer.
|
||||
offset = 0;
|
||||
for (int i = 0; i < items; i++) {
|
||||
for (uint8_t i = 0; i < this->curItems; i++) {
|
||||
attrset(CRT_colors[Meter_attributes(this)[i]]);
|
||||
mvaddnstr(y, x + offset, bar + offset, blockSizes[i]);
|
||||
offset += blockSizes[i];
|
||||
|
@ -296,8 +295,7 @@ static void GraphMeterMode_draw(Meter* this, int x, int y, int w) {
|
|||
Meter_updateValues(this, buffer, nValues - 1);
|
||||
|
||||
double value = 0.0;
|
||||
int items = this->curItems;
|
||||
for (int i = 0; i < items; i++)
|
||||
for (uint8_t i = 0; i < this->curItems; i++)
|
||||
value += this->values[i];
|
||||
value /= this->total;
|
||||
data->values[nValues - 1] = value;
|
||||
|
|
4
Meter.h
4
Meter.h
|
@ -42,7 +42,7 @@ typedef struct MeterClass_ {
|
|||
const char* const uiName;
|
||||
const char* const caption;
|
||||
const char* const description;
|
||||
const char maxItems;
|
||||
const uint8_t maxItems;
|
||||
} MeterClass;
|
||||
|
||||
#define As_Meter(this_) ((const MeterClass*)((this_)->super.klass))
|
||||
|
@ -75,7 +75,7 @@ struct Meter_ {
|
|||
GraphData* drawData;
|
||||
int h;
|
||||
const ProcessList* pl;
|
||||
char curItems;
|
||||
uint8_t curItems;
|
||||
double* values;
|
||||
double total;
|
||||
void* meterData;
|
||||
|
|
Loading…
Reference in New Issue