From eeeba719af15b1e86d612e289d16a880123feeaa Mon Sep 17 00:00:00 2001 From: Andrey Semashev Date: Wed, 27 Jul 2022 08:45:40 +0300 Subject: [PATCH] mem: Correct calculation of total mem size in mem_status (#459) --- src/mem/mem.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/mem/mem.c b/src/mem/mem.c index 7fa0bb79c..945247f6c 100644 --- a/src/mem/mem.c +++ b/src/mem/mem.c @@ -525,18 +525,19 @@ int mem_status(struct re_printf *pf, void *unused) c = list_count(&meml); mem_unlock(); - err |= re_hprintf(pf, "Memory status: (%zu bytes overhead pr block)\n", + err |= re_hprintf(pf, + "Memory status: (%zu bytes overhead per block)\n", (size_t)mem_header_size); err |= re_hprintf(pf, " Cur: %zu blocks, %zu bytes (total %zu bytes)\n", stat.blocks_cur, stat.bytes_cur, stat.bytes_cur - +(stat.blocks_cur*sizeof(struct mem))); + + (stat.blocks_cur * (size_t)mem_header_size)); err |= re_hprintf(pf, " Peak: %zu blocks, %zu bytes (total %zu bytes)\n", stat.blocks_peak, stat.bytes_peak, stat.bytes_peak - +(stat.blocks_peak*sizeof(struct mem))); + + (stat.blocks_peak * (size_t)mem_header_size)); err |= re_hprintf(pf, " Total %u blocks allocated\n", c); return err;