summaryrefslogtreecommitdiff
path: root/libc/stdlib/malloc-standard/mallinfo.c
diff options
context:
space:
mode:
authorEric Andersen <andersen@codepoet.org>2004-11-08 03:34:44 +0000
committerEric Andersen <andersen@codepoet.org>2004-11-08 03:34:44 +0000
commit76dfc7ce8cff868d547bcfde6fae0cba9f6efa25 (patch)
tree31f186b2c8e3a03929ca372b8ddfc184835b6d07 /libc/stdlib/malloc-standard/mallinfo.c
parent909aec10fe871c86655e4f0452e2479f9240e4f4 (diff)
Some requested additional malloc entry points
Diffstat (limited to 'libc/stdlib/malloc-standard/mallinfo.c')
-rw-r--r--libc/stdlib/malloc-standard/mallinfo.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/libc/stdlib/malloc-standard/mallinfo.c b/libc/stdlib/malloc-standard/mallinfo.c
index 89d6b68e1..f35aab00f 100644
--- a/libc/stdlib/malloc-standard/mallinfo.c
+++ b/libc/stdlib/malloc-standard/mallinfo.c
@@ -79,3 +79,28 @@ struct mallinfo mallinfo(void)
return mi;
}
+void malloc_stats(FILE *file)
+{
+ struct mallinfo mi;
+
+ if (file==NULL) {
+ file = stderr;
+ }
+
+ mi = mallinfo();
+ fprintf(file, "total bytes allocated = %10lu\n", (unsigned int)(mi.arena + mi.hblkhd));
+ fprintf(file, "total bytes in use bytes = %10lu\n", (unsigned int)(mi.uordblks + mi.hblkhd));
+ fprintf(file, "total non-mmapped bytes allocated = %10lu\n", (unsigned int)(mi.arena));
+ fprintf(file, "number of mmapped regions = %10lu\n", (unsigned int)(mi.hblks));
+ fprintf(file, "total allocated mmap space = %10lu\n", (unsigned int)(mi.hblkhd));
+ fprintf(file, "total allocated sbrk space = %10lu\n", (unsigned int)(mi.uordblks));
+#if 0
+ fprintf(file, "number of free chunks = %10lu\n", (unsigned int)(mi.ordblks));
+ fprintf(file, "number of fastbin blocks = %10lu\n", (unsigned int)(mi.smblks));
+ fprintf(file, "space in freed fastbin blocks = %10lu\n", (unsigned int)(mi.fsmblks));
+#endif
+ fprintf(file, "maximum total allocated space = %10lu\n", (unsigned int)(mi.usmblks));
+ fprintf(file, "total free space = %10lu\n", (unsigned int)(mi.fordblks));
+ fprintf(file, "memory releasable via malloc_trim = %10lu\n", (unsigned int)(mi.keepcost));
+}
+