From 5028771e6ffa280b82ea5b697404f45016a46e63 Mon Sep 17 00:00:00 2001 From: John Cupitt Date: Fri, 3 Feb 2012 10:37:10 +0000 Subject: [PATCH] always print mem high-water on leak check --- libvips/iofuncs/init.c | 10 ++++++---- libvipsCC/VImage.cc | 8 ++++++++ libvipsCC/include/vips/VImage.h | 3 +++ swig/vipsCC/VImage.i | 6 ++++++ swig/vipsCC/test.py | 4 ++++ 5 files changed, 27 insertions(+), 4 deletions(-) create mode 100644 swig/vipsCC/test.py diff --git a/libvips/iofuncs/init.c b/libvips/iofuncs/init.c index 84cb46f4..db153192 100644 --- a/libvips/iofuncs/init.c +++ b/libvips/iofuncs/init.c @@ -301,13 +301,15 @@ vips_leak( void ) 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 ) ); } + + vips_buf_appendf( &buf, "memory: high-water mark " ); + vips_buf_append_size( &buf, vips_tracked_get_mem_highwater() ); + vips_buf_appends( &buf, "\n" ); + + fprintf( stderr, "%s", vips_buf_all( &buf ) ); } /** diff --git a/libvipsCC/VImage.cc b/libvipsCC/VImage.cc index dff543a4..c40be8aa 100644 --- a/libvipsCC/VImage.cc +++ b/libvipsCC/VImage.cc @@ -444,6 +444,14 @@ void VImage::initdesc( int x, int y, int b, verror(); } +// used to test SWIG wrappers with output args +double VImage::test_member( double a, double b, double *c, double *d ) +{ + *c = a + b; + *d = a - b; + return a * b; +} + // Create a Vargv from a name Vargv::Vargv( const char *name ) { diff --git a/libvipsCC/include/vips/VImage.h b/libvipsCC/include/vips/VImage.h index b9d426c4..65303e34 100644 --- a/libvipsCC/include/vips/VImage.h +++ b/libvipsCC/include/vips/VImage.h @@ -288,6 +288,9 @@ public: void initdesc( int, int, int, TBandFmt, TCoding, TType, float = 1.0, float = 1.0, int = 0, int = 0 ) throw( VError ); + // test member for SWIG output args + double test_member( double a, double b, double *c, double *d ); + /* Insert automatically generated headers. */ #include "vipsc++.h" diff --git a/swig/vipsCC/VImage.i b/swig/vipsCC/VImage.i index 35ace859..cf840307 100644 --- a/swig/vipsCC/VImage.i +++ b/swig/vipsCC/VImage.i @@ -33,6 +33,7 @@ %include "std_except.i" %include "std_string.i" %include "cstring.i" +%include "typemaps.i" %import "VError.i" %import "VMask.i" @@ -79,6 +80,11 @@ struct VBuffer { */ %include VImage.h +/* Some operations return values though their params. We have to note these + * specially. + */ +extern double vips::VImage::maxpos_avg(double &OUTPUT, double &OUTPUT); + %extend vips::VImage { public: VBuffer tobuffer () throw (VError) diff --git a/swig/vipsCC/test.py b/swig/vipsCC/test.py new file mode 100644 index 00000000..50699254 --- /dev/null +++ b/swig/vipsCC/test.py @@ -0,0 +1,4 @@ +from vipsCC import * + +a = VImage.VImage("/home/john/pics/shark.jpg") +print a.maxpos_avg()