diff options
author | Hisham Muhammad <hisham@gobolinux.org> | 2009-06-02 04:51:23 +0000 |
---|---|---|
committer | Hisham Muhammad <hisham@gobolinux.org> | 2009-06-02 04:51:23 +0000 |
commit | 6330ff3a0ac6d279132d36cea027ad3f065707b1 (patch) | |
tree | 70d894309bb92c9146fc4063e41d68686ffcfafd /CPUMeter.c | |
parent | 1371ee28a7e953052e414dfd1641294852aa4458 (diff) |
changes for htop 0.8.2
Diffstat (limited to 'CPUMeter.c')
-rw-r--r-- | CPUMeter.c | 8 |
1 files changed, 8 insertions, 0 deletions
@@ -43,6 +43,10 @@ static void CPUMeter_init(Meter* this) { static void CPUMeter_setValues(Meter* this, char* buffer, int size) { ProcessList* pl = this->pl; int processor = this->param; + if (processor > this->pl->processorCount) { + snprintf(buffer, size, "absent"); + return; + } double total = (double) pl->totalPeriod[processor]; double cpu; this->values[0] = pl->nicePeriod[processor] / total * 100.0; @@ -67,6 +71,10 @@ static void CPUMeter_display(Object* cast, RichString* out) { char buffer[50]; Meter* this = (Meter*)cast; RichString_init(out); + if (this->param > this->pl->processorCount) { + RichString_append(out, CRT_colors[METER_TEXT], "absent"); + return; + } sprintf(buffer, "%5.1f%% ", this->values[1]); RichString_append(out, CRT_colors[METER_TEXT], ":"); RichString_append(out, CRT_colors[CPU_NORMAL], buffer); |