diff --git a/ChangeLog b/ChangeLog index 064dd8a0..4f3488f3 100644 --- a/ChangeLog +++ b/ChangeLog @@ -16,6 +16,7 @@ - cache limits, drop, init, flush plus command-line controls - remove dmalloc support, was never used and valgrind is better - im_csv2vips() allows quoted strings, including escaped quotes +- added vips_shutdown() 10/8/11 started 7.26.3 - don't use G_VALUE_COLLECT_INIT(), many platforms do not have a glib this diff --git a/TODO b/TODO index bfb8e0d1..cea230d0 100644 --- a/TODO +++ b/TODO @@ -8,7 +8,8 @@ - add vips_init_argv() which processes argc/argv for you? handy for tiny progs, perhaps -- add vips_shutdown()? unload plugins, drop cache etc. +- add vips_shutdown()? unload plugins, drop cache etc. could test for leaks + too diff --git a/libvips/include/vips/vips.h b/libvips/include/vips/vips.h index edb098a2..9661a376 100644 --- a/libvips/include/vips/vips.h +++ b/libvips/include/vips/vips.h @@ -150,6 +150,7 @@ extern "C" { const char *vips_get_argv0( void ); int vips_init( const char *argv0 ); void vips_check_init( void ); +void vips_shutdown( void ); GOptionGroup *vips_get_option_group( void ); const char *vips_version_string( void ); diff --git a/libvips/iofuncs/init.c b/libvips/iofuncs/init.c index 8b78dd2a..dbdc8a08 100644 --- a/libvips/iofuncs/init.c +++ b/libvips/iofuncs/init.c @@ -145,12 +145,14 @@ vips_get_argv0( void ) * if( vips_init( argv[0] ) ) * vips_error_exit( "unable to start VIPS" ); * + * vips_shutdown(); + * * return( 0 ); * } * ]| * - * See also: vips_get_option_group(), vips_version(), vips_guess_prefix(), - * vips_guess_libdir(). + * See also: vips_shutdown(), vips_get_option_group(), vips_version(), + * vips_guess_prefix(), vips_guess_libdir(). * * Returns: 0 on success, -1 otherwise */ @@ -274,6 +276,25 @@ vips_check_init( void ) vips_error_clear(); } +/** + * vips_shutdown: + * + * Call this to drop caches and close plugins. Handy if you're doing leak + * checks. + */ +void +vips_shutdown( void ) +{ + im_close_plugins(); + vips_cache_drop_all(); + +#ifdef DEBUG_LEAK + printf( "** leak test on exit:\n" ); + im__print_all(); + printf( "** leak test done\n" ); +#endif /*DEBUG_LEAK*/ +} + const char * vips__gettext( const char *msgid ) { diff --git a/tools/edvips.c b/tools/edvips.c index 089006d4..3ea8a90d 100644 --- a/tools/edvips.c +++ b/tools/edvips.c @@ -207,6 +207,8 @@ main( int argc, char **argv ) im_close( im ); + vips_shutdown(); + return( 0 ); } diff --git a/tools/find_mosaic.c b/tools/find_mosaic.c index 11e5d0c7..33ef1f06 100644 --- a/tools/find_mosaic.c +++ b/tools/find_mosaic.c @@ -436,6 +436,7 @@ char **argv; error_exit("unable to close\n "); fclose( fp ); + vips_shutdown(); return( 0 ); } diff --git a/tools/header.c b/tools/header.c index f5cf2ecd..72516878 100644 --- a/tools/header.c +++ b/tools/header.c @@ -204,5 +204,7 @@ main( int argc, char *argv[] ) im_close( im ); } + vips_shutdown(); + return( result ); } diff --git a/tools/mergeup.c b/tools/mergeup.c index 166f1a94..5a366b74 100644 --- a/tools/mergeup.c +++ b/tools/mergeup.c @@ -560,5 +560,7 @@ char **argv; if( im_close(out) == -1) error_exit("unable to close\n "); + vips_shutdown(); + return( 0 ); } diff --git a/tools/vips.c b/tools/vips.c index 206a6790..e506fae0 100644 --- a/tools/vips.c +++ b/tools/vips.c @@ -1127,14 +1127,7 @@ main( int argc, char **argv ) g_option_context_free( context ); - im_close_plugins(); - vips_cache_drop_all(); - -#ifdef DEBUG_LEAK - printf( "** leak test on exit:\n" ); - im__print_all(); - printf( "** leak test done\n" ); -#endif /*DEBUG_LEAK*/ + vips_shutdown(); return( 0 ); } diff --git a/tools/vipsthumbnail.c b/tools/vipsthumbnail.c index 81aa01b7..3c0ee5c8 100644 --- a/tools/vipsthumbnail.c +++ b/tools/vipsthumbnail.c @@ -405,5 +405,7 @@ main( int argc, char **argv ) im_error_clear(); } + vips_shutdown(); + return( 0 ); }