add vips_shutdown()

vips_shutdown() flushes caches, closes plugins and does a leak check
This commit is contained in:
John Cupitt 2011-09-24 10:17:32 +01:00
parent 2003b5b524
commit 13e354e869
10 changed files with 37 additions and 11 deletions

View File

@ -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

3
TODO
View File

@ -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

View File

@ -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 );

View File

@ -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 )
{

View File

@ -207,6 +207,8 @@ main( int argc, char **argv )
im_close( im );
vips_shutdown();
return( 0 );
}

View File

@ -436,6 +436,7 @@ char **argv;
error_exit("unable to close\n ");
fclose( fp );
vips_shutdown();
return( 0 );
}

View File

@ -204,5 +204,7 @@ main( int argc, char *argv[] )
im_close( im );
}
vips_shutdown();
return( result );
}

View File

@ -560,5 +560,7 @@ char **argv;
if( im_close(out) == -1)
error_exit("unable to close\n ");
vips_shutdown();
return( 0 );
}

View File

@ -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 );
}

View File

@ -405,5 +405,7 @@ main( int argc, char **argv )
im_error_clear();
}
vips_shutdown();
return( 0 );
}