From 283707c5e5bc436b78ea23bf5500cb6b16a01148 Mon Sep 17 00:00:00 2001 From: Daniel Lange Date: Mon, 11 Apr 2016 13:00:27 +0200 Subject: Imported Upstream version 0.9 --- MemoryMeter.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) (limited to 'MemoryMeter.c') diff --git a/MemoryMeter.c b/MemoryMeter.c index 43215eb..e3e18ec 100644 --- a/MemoryMeter.c +++ b/MemoryMeter.c @@ -1,6 +1,6 @@ /* htop -(C) 2004-2006 Hisham H. Muhammad +(C) 2004-2010 Hisham H. Muhammad Released under the GNU GPL, see the COPYING file in the source distribution for its full text. */ @@ -38,13 +38,12 @@ static void MemoryMeter_setValues(Meter* this, char* buffer, int size) { static void MemoryMeter_display(Object* cast, RichString* out) { char buffer[50]; Meter* this = (Meter*)cast; - int div = 1024; char* format = "%ldM "; - long int totalMem = this->total / div; - long int usedMem = this->values[0] / div; - long int buffersMem = this->values[1] / div; - long int cachedMem = this->values[2] / div; - RichString_init(out); - RichString_append(out, CRT_colors[METER_TEXT], ":"); + int k = 1024; const char* format = "%ldM "; + long int totalMem = this->total / k; + long int usedMem = this->values[0] / k; + long int buffersMem = this->values[1] / k; + long int cachedMem = this->values[2] / k; + RichString_write(out, CRT_colors[METER_TEXT], ":"); sprintf(buffer, format, totalMem); RichString_append(out, CRT_colors[METER_VALUE], buffer); sprintf(buffer, format, usedMem); -- cgit v1.2.3