From 06e01f311ea4154c3ef797befa29cbf3ff19a4b0 Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Sat, 13 Aug 2011 05:32:53 +0000 Subject: [PATCH] memcheck/tests/sbfragment.c: Only use mallinfo() if available. git-svn-id: svn://svn.valgrind.org/valgrind/trunk@11970 --- memcheck/tests/sbfragment.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/memcheck/tests/sbfragment.c b/memcheck/tests/sbfragment.c index bd2bd122fc..0c09b823aa 100644 --- a/memcheck/tests/sbfragment.c +++ b/memcheck/tests/sbfragment.c @@ -1,16 +1,24 @@ #include #include +#include "../../config.h" +#if defined(HAVE_MALLINFO) #include +#endif #define BIGINCREASE 32000 int debug = 0; void stats(char *msg) { +#if defined(HAVE_MALLINFO) struct mallinfo mallinfo_result; mallinfo_result = mallinfo(); +#endif + /* from /usr/include/malloc.h */ printf("%s\n", msg); + +#if defined(HAVE_MALLINFO) printf("%10d int arena; /* non-mmapped space allocated from system */\n", mallinfo_result.arena); printf("%10d int ordblks; /* number of free chunks */\n", mallinfo_result.ordblks); printf("%10d int smblks; /* number of fastbin blocks */\n", mallinfo_result.smblks); @@ -22,6 +30,7 @@ void stats(char *msg) printf("%10d int fordblks; /* total free space */\n", mallinfo_result.fordblks); printf("%10d int keepcost; /* top-most, releasable (via malloc_trim) space */\n", mallinfo_result.keepcost); printf("\n"); +#endif } int main(int argc, char *argv[]) @@ -68,6 +77,7 @@ int main(int argc, char *argv[]) printf ("after %d loops, last size block requested %lu\n", loop, bigsize); // verify if superblock fragmentation occured // We consider that an arena of up to 3 times more than bigsize is ok. +#if defined(HAVE_MALLINFO) { struct mallinfo mallinfo_result; mallinfo_result = mallinfo(); @@ -82,6 +92,7 @@ int main(int argc, char *argv[]) else printf("reasonable heap usage\n"); } +#endif if (debug) stats ("before freeing last block"); -- 2.47.3