atrstm

Load and structure a combustion gas mixture
git clone git://git.meso-star.fr/atrstm.git
Log | Files | Refs | README | LICENSE

commit 755a67919baf32fd8429d9d13b653b6e87a9cf4e
parent d5dc1afde8e99ca425cd9dd0dc6ee8f608ea27f5
Author: Vincent Forest <vincent.forest@meso-star.com>
Date:   Thu, 21 Jan 2021 09:36:35 +0100

Fix the dump_memory_size function

Remove trailing white space and correctly compute the "real_dump_len".

Diffstat:
Msrc/atrstm.c | 13++++++++++---
1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/src/atrstm.c b/src/atrstm.c @@ -66,7 +66,7 @@ release_atrstm(ref_T* ref) if(atrstm->suvm) SUVM(device_ref_put(atrstm->suvm)); if(atrstm->volume) SUVM(volume_ref_put(atrstm->volume)); if(atrstm->svx) SVX(device_ref_put(atrstm->svx)); - if(atrstm->cache) cache_ref_put(atrstm->cache); + if(atrstm->cache) cache_ref_put(atrstm->cache); if(atrstm->logger == &atrstm->logger__) logger_release(&atrstm->logger__); str_release(&atrstm->name); ASSERT(MEM_ALLOCATED_SIZE(&atrstm->svx_allocator) == 0); @@ -247,7 +247,7 @@ dump_memory_size "%li %s", (long)Size, Size > 1 ? Suffix "s ": Suffix " "); \ ASSERT(len >= 0); \ if(real_dump_len) { \ - real_dump_len += len; \ + *real_dump_len += (size_t)len; \ } \ if((size_t)len < available_dump_space) { \ dst += len; \ @@ -270,6 +270,13 @@ dump_memory_size DUMP(nkilos, "kB"); nbytes -= nkilos * KILO_BYTE; } - DUMP(nbytes, "Byte"); + if(nbytes) { + DUMP(nbytes, "Byte"); + } + + /* Remove last space */ + if(real_dump_len) *real_dump_len -= 1; + if(dst != dump && dst[-1] == ' ') dst[-1] = '\0'; + #undef DUMP }