diff options
author | Christian Göttsche <cgzones@googlemail.com> | 2020-11-24 19:34:27 +0100 |
---|---|---|
committer | Benny Baumann <BenBE@geshi.org> | 2020-12-06 16:03:44 +0100 |
commit | ad764ff972082608604634c84e5427e7bfdcda1a (patch) | |
tree | 3b4cb72205d708563bd9baf62ef2039dc8bafdac /MemoryMeter.c | |
parent | 77ec86aff4314afd893baed0d16d7bd52c387fd4 (diff) |
Introduce METER_BUFFER_CHECK and METER_BUFFER_APPEND_CHR to cleanup writing to bar buffers
Closes: #294
Diffstat (limited to 'MemoryMeter.c')
-rw-r--r-- | MemoryMeter.c | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/MemoryMeter.c b/MemoryMeter.c index 5e334a93..9830bf51 100644 --- a/MemoryMeter.c +++ b/MemoryMeter.c @@ -24,12 +24,11 @@ static void MemoryMeter_updateValues(Meter* this, char* buffer, size_t size) { Platform_setMemoryValues(this); written = Meter_humanUnit(buffer, this->values[0], size); - buffer += written; - if ((size -= written) > 0) { - *buffer++ = '/'; - size--; - Meter_humanUnit(buffer, this->total, size); - } + METER_BUFFER_CHECK(buffer, size, written); + + METER_BUFFER_APPEND_CHR(buffer, size, '/'); + + Meter_humanUnit(buffer, this->total, size); } static void MemoryMeter_display(const Object* cast, RichString* out) { |