From c5c2cf5f2b51ab867c5630d16b199294528fe801 Mon Sep 17 00:00:00 2001 From: John Cupitt Date: Mon, 14 Nov 2011 08:51:09 +0000 Subject: [PATCH] only pront a leak message if there's a leak --- libvips/iofuncs/init.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/libvips/iofuncs/init.c b/libvips/iofuncs/init.c index 8be179b0..51f7d589 100644 --- a/libvips/iofuncs/init.c +++ b/libvips/iofuncs/init.c @@ -295,14 +295,19 @@ vips_leak( void ) vips_object_print_all(); - vips_buf_appendf( &buf, "memory: %d allocations, %zd bytes\n", - vips_tracked_get_allocs(), vips_tracked_get_mem() ); - vips_buf_appendf( &buf, "memory: high-water mark " ); - vips_buf_append_size( &buf, vips_tracked_get_mem_highwater() ); - vips_buf_appendf( &buf, "\nfiles: %d open\n", - vips_tracked_get_files() ); + if( vips_tracked_get_allocs() || + vips_tracked_get_mem() || + vips_tracked_get_mem_highwater() || + vips_tracked_get_files() ) { + vips_buf_appendf( &buf, "memory: %d allocations, %zd bytes\n", + vips_tracked_get_allocs(), vips_tracked_get_mem() ); + vips_buf_appendf( &buf, "memory: high-water mark " ); + vips_buf_append_size( &buf, vips_tracked_get_mem_highwater() ); + vips_buf_appendf( &buf, "\nfiles: %d open\n", + vips_tracked_get_files() ); - fprintf( stderr, "%s", vips_buf_all( &buf ) ); + fprintf( stderr, "%s", vips_buf_all( &buf ) ); + } } /**