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;
|
int cpu = this->param;
|
||||||
if (cpu > this->pl->cpuCount) {
|
if (cpu > this->pl->cpuCount) {
|
||||||
xSnprintf(buffer, size, "absent");
|
xSnprintf(buffer, size, "absent");
|
||||||
int items = this->curItems;
|
for (uint8_t i = 0; i < this->curItems; i++)
|
||||||
for (int i = 0; i < items; i++)
|
|
||||||
this->values[i] = 0;
|
this->values[i] = 0;
|
||||||
return;
|
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...
|
// First draw in the bar[] buffer...
|
||||||
int offset = 0;
|
int offset = 0;
|
||||||
int items = this->curItems;
|
for (uint8_t i = 0; i < this->curItems; i++) {
|
||||||
for (int i = 0; i < items; i++) {
|
|
||||||
double value = this->values[i];
|
double value = this->values[i];
|
||||||
value = CLAMP(value, 0.0, this->total);
|
value = CLAMP(value, 0.0, this->total);
|
||||||
if (value > 0) {
|
if (value > 0) {
|
||||||
|
@ -220,7 +219,7 @@ static void BarMeterMode_draw(Meter* this, int x, int y, int w) {
|
||||||
|
|
||||||
// ...then print the buffer.
|
// ...then print the buffer.
|
||||||
offset = 0;
|
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]]);
|
attrset(CRT_colors[Meter_attributes(this)[i]]);
|
||||||
mvaddnstr(y, x + offset, bar + offset, blockSizes[i]);
|
mvaddnstr(y, x + offset, bar + offset, blockSizes[i]);
|
||||||
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);
|
Meter_updateValues(this, buffer, nValues - 1);
|
||||||
|
|
||||||
double value = 0.0;
|
double value = 0.0;
|
||||||
int items = this->curItems;
|
for (uint8_t i = 0; i < this->curItems; i++)
|
||||||
for (int i = 0; i < items; i++)
|
|
||||||
value += this->values[i];
|
value += this->values[i];
|
||||||
value /= this->total;
|
value /= this->total;
|
||||||
data->values[nValues - 1] = value;
|
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 uiName;
|
||||||
const char* const caption;
|
const char* const caption;
|
||||||
const char* const description;
|
const char* const description;
|
||||||
const char maxItems;
|
const uint8_t maxItems;
|
||||||
} MeterClass;
|
} MeterClass;
|
||||||
|
|
||||||
#define As_Meter(this_) ((const MeterClass*)((this_)->super.klass))
|
#define As_Meter(this_) ((const MeterClass*)((this_)->super.klass))
|
||||||
|
@ -75,7 +75,7 @@ struct Meter_ {
|
||||||
GraphData* drawData;
|
GraphData* drawData;
|
||||||
int h;
|
int h;
|
||||||
const ProcessList* pl;
|
const ProcessList* pl;
|
||||||
char curItems;
|
uint8_t curItems;
|
||||||
double* values;
|
double* values;
|
||||||
double total;
|
double total;
|
||||||
void* meterData;
|
void* meterData;
|
||||||
|
|
Loading…
Reference in New Issue