merge fprintf/fputs calls in malloc_info

This commit is contained in:
Daniel Micay 2023-02-17 12:19:47 -05:00
parent 6038030d0b
commit 2e9daf3122

View File

@ -1883,12 +1883,13 @@ EXPORT int h_malloc_info(int options, FILE *fp) {
mutex_unlock(&c->lock); mutex_unlock(&c->lock);
if (nmalloc || ndalloc || slab_allocated || allocated) { if (nmalloc || ndalloc || slab_allocated || allocated) {
fprintf(fp, "<bin nr=\"%u\" size=\"%" PRIu32 "\">", class, size_classes[class]); fprintf(fp, "<bin nr=\"%u\" size=\"%" PRIu32 "\">"
fprintf(fp, "<nmalloc>%" PRIu64 "</nmalloc>", nmalloc); "<nmalloc>%" PRIu64 "</nmalloc>"
fprintf(fp, "<ndalloc>%" PRIu64 "</ndalloc>", ndalloc); "<ndalloc>%" PRIu64 "</ndalloc>"
fprintf(fp, "<slab_allocated>%zu</slab_allocated>", slab_allocated); "<slab_allocated>%zu</slab_allocated>"
fprintf(fp, "<allocated>%zu</allocated>", allocated); "<allocated>%zu</allocated>"
fputs("</bin>", fp); "</bin>", class, size_classes[class], nmalloc, ndalloc, slab_allocated,
allocated);
} }
} }
@ -1900,9 +1901,9 @@ EXPORT int h_malloc_info(int options, FILE *fp) {
size_t region_allocated = ra->allocated; size_t region_allocated = ra->allocated;
mutex_unlock(&ra->lock); mutex_unlock(&ra->lock);
fprintf(fp, "<heap nr=\"%u\">", N_ARENA); fprintf(fp, "<heap nr=\"%u\">"
fprintf(fp, "<allocated_large>%zu</allocated_large>", region_allocated); "<allocated_large>%zu</allocated_large>"
fputs("</heap>", fp); "</heap>", N_ARENA, region_allocated);
thread_seal_metadata(); thread_seal_metadata();
} }