"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "libvips/iofuncs/init.c" between
vips-8.10.6.tar.gz and vips-8.11.0.tar.gz

About: VIPS is a free image processing system (see also the GUI nip2).

init.c  (vips-8.10.6):init.c  (vips-8.11.0)
skipping to change at line 93 skipping to change at line 93
#endif /*HAVE_SYS_PARAM_H*/ #endif /*HAVE_SYS_PARAM_H*/
#ifdef HAVE_UNISTD_H #ifdef HAVE_UNISTD_H
#include <unistd.h> #include <unistd.h>
#endif /*HAVE_UNISTD_H*/ #endif /*HAVE_UNISTD_H*/
#ifdef HAVE_DIRECT_H #ifdef HAVE_DIRECT_H
#include <direct.h> #include <direct.h>
#endif /*HAVE_DIRECT_H*/ #endif /*HAVE_DIRECT_H*/
#include <limits.h> #include <limits.h>
#include <string.h> #include <string.h>
/* Disable deprecation warnings from gsf. There are loads, and still not
* patched as of 12/2020.
*/
#ifdef HAVE_GSF #ifdef HAVE_GSF
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
#include <gsf/gsf.h> #include <gsf/gsf.h>
#pragma GCC diagnostic pop
#endif /*HAVE_GSF*/ #endif /*HAVE_GSF*/
#include <vips/vips.h> #include <vips/vips.h>
#include <vips/thread.h> #include <vips/thread.h>
#include <vips/internal.h> #include <vips/internal.h>
#include <vips/vector.h> #include <vips/vector.h>
#if ENABLE_DEPRECATED #if ENABLE_DEPRECATED
#include <vips/vips7compat.h> #include <vips/vips7compat.h>
#endif #endif
skipping to change at line 123 skipping to change at line 129
GMutex *vips__global_lock = NULL; GMutex *vips__global_lock = NULL;
/* A debugging timer, zero at library init. /* A debugging timer, zero at library init.
*/ */
GTimer *vips__global_timer = NULL; GTimer *vips__global_timer = NULL;
/* Keep a copy of the argv0 here. /* Keep a copy of the argv0 here.
*/ */
static char *vips__argv0 = NULL; static char *vips__argv0 = NULL;
/* Keep a copy of the last component of argv0 here.
*/
static char *vips__prgname = NULL;
/* Leak check on exit. /* Leak check on exit.
*/ */
int vips__leak = 0; int vips__leak = 0;
#ifdef DEBUG_LEAK #ifdef DEBUG_LEAK
/* Count pixels processed per image here. /* Count pixels processed per image here.
*/ */
GQuark vips__image_pixels_quark = 0; GQuark vips__image_pixels_quark = 0;
#endif /*DEBUG_LEAK*/ #endif /*DEBUG_LEAK*/
static gint64 vips_pipe_read_limit = 1024 * 1024 * 1024; static gint64 vips_pipe_read_limit = 1024 * 1024 * 1024;
/** /**
* vips_get_argv0: * vips_get_argv0:
* *
* See also: VIPS_INIT(). * See also: VIPS_INIT().
* *
* Returns: a pointer to an internal copy of the argv0 string passed to * Returns: (transfer none): a pointer to an internal copy of the
* argv0 string passed to
* VIPS_INIT(). Do not free this value * VIPS_INIT(). Do not free this value
*/ */
const char * const char *
vips_get_argv0( void ) vips_get_argv0( void )
{ {
return( vips__argv0 ); return( vips__argv0 );
} }
/** /**
* vips_get_prgname:
*
* Return the program name. This can be useful for the user tio see,.
*
* See also: VIPS_INIT().
*
* Returns: (transfer none): a pointer to an internal copy of the program
* name. Do not free this value
*/
const char *
vips_get_prgname( void )
{
const char *prgname;
if( (prgname = g_get_prgname()) )
return( prgname );
else
return( vips__prgname );
}
/**
* VIPS_INIT: * VIPS_INIT:
* @ARGV0: name of application * @ARGV0: name of application
* *
* gtk-doc mistakenly tags this macro as deprecated for unknown reasons. It is * gtk-doc mistakenly tags this macro as deprecated for unknown reasons. It is
* *NOT* deprecated, please ignore the warning above. * *NOT* deprecated, please ignore the warning above.
* *
* VIPS_INIT() starts up the world of VIPS. You should call this on * VIPS_INIT() starts up the world of VIPS. You should call this on
* program startup before using any other VIPS operations. If you do not call * program startup before using any other VIPS operations. If you do not call
* VIPS_INIT(), VIPS will call it for you when you use your first VIPS * VIPS_INIT(), VIPS will call it for you when you use your first VIPS
* operation, but it may not be able to get hold of @ARGV0 and VIPS may * operation, but it may not be able to get hold of @ARGV0 and VIPS may
skipping to change at line 224 skipping to change at line 256
* return 0; * return 0;
* } * }
* ]| * ]|
* *
* See also: vips_shutdown(), vips_add_option_entries(), vips_version(), * See also: vips_shutdown(), vips_add_option_entries(), vips_version(),
* vips_guess_prefix(), vips_guess_libdir(). * vips_guess_prefix(), vips_guess_libdir().
* *
* Returns: 0 on success, -1 otherwise * Returns: 0 on success, -1 otherwise
*/ */
/* Load all plugins in a directory ... look for '.plg' suffix. Error if we had /* Load all plugins in a directory ... look for '.<G_MODULE_SUFFIX>' or
* any probs. * '.plg' (deprecated) suffix. Error if we had any probs.
*/ */
static int static int
vips_load_plugins( const char *fmt, ... ) vips_load_plugins( const char *fmt, ... )
{ {
va_list ap; va_list ap;
char dir_name[VIPS_PATH_MAX]; char dir_name[VIPS_PATH_MAX];
GDir *dir; GDir *dir;
const char *name; const char *name;
int result; int result;
skipping to change at line 256 skipping to change at line 288
printf( "vips_load_plugins: searching \"%s\"\n", dir_name ); printf( "vips_load_plugins: searching \"%s\"\n", dir_name );
#endif /*DEBUG*/ #endif /*DEBUG*/
if( !(dir = g_dir_open( dir_name, 0, NULL )) ) if( !(dir = g_dir_open( dir_name, 0, NULL )) )
/* Silent success for dir not there. /* Silent success for dir not there.
*/ */
return( 0 ); return( 0 );
result = 0; result = 0;
while( (name = g_dir_read_name( dir )) ) while( (name = g_dir_read_name( dir )) )
if( vips_ispostfix( name, ".plg" ) ) { if( vips_ispostfix( name, "." G_MODULE_SUFFIX )
#if ENABLE_DEPRECATED
|| vips_ispostfix( name, ".plg" )
#endif
) {
char path[VIPS_PATH_MAX]; char path[VIPS_PATH_MAX];
GModule *module; GModule *module;
vips_snprintf( path, VIPS_PATH_MAX - 1, vips_snprintf( path, VIPS_PATH_MAX - 1,
"%s" G_DIR_SEPARATOR_S "%s", dir_name, name ); "%s" G_DIR_SEPARATOR_S "%s", dir_name, name );
#ifdef DEBUG #ifdef DEBUG
printf( "vips_load_plugins: loading \"%s\"\n", path ); printf( "vips_load_plugins: loading \"%s\"\n", path );
#endif /*DEBUG*/ #endif /*DEBUG*/
skipping to change at line 287 skipping to change at line 323
} }
/* Install this log handler to hide warning messages. /* Install this log handler to hide warning messages.
*/ */
static void static void
empty_log_handler( const gchar *log_domain, GLogLevelFlags log_level, empty_log_handler( const gchar *log_domain, GLogLevelFlags log_level,
const gchar *message, gpointer user_data ) const gchar *message, gpointer user_data )
{ {
} }
#if !GLIB_CHECK_VERSION( 2, 31, 0 )
static void
default_log_handler( const gchar *log_domain, GLogLevelFlags log_level,
const gchar *message, gpointer user_data )
{
if( log_level & (G_LOG_LEVEL_DEBUG | G_LOG_LEVEL_INFO) ) {
const char *domains = g_getenv( "G_MESSAGES_DEBUG" );
if( !domains ||
(!g_str_equal( domains, "all" ) &&
!g_strrstr( domains, log_domain )) )
return;
}
g_log_default_handler( log_domain, log_level, message, user_data );
}
#endif /*!GLIB_CHECK_VERSION( 2, 31, 0 )*/
/* Attempt to set a minimum stacksize. This can be important on systems with a /* Attempt to set a minimum stacksize. This can be important on systems with a
* very low default, like musl. * very low default, like musl.
*/ */
static void static void
set_stacksize( guint64 size ) set_stacksize( guint64 size )
{ {
#ifdef HAVE_PTHREAD_DEFAULT_NP #ifdef HAVE_PTHREAD_DEFAULT_NP
pthread_attr_t attr; pthread_attr_t attr;
guint64 cur_stack_size; size_t cur_stack_size;
/* Don't allow stacks less than 2mb. /* Don't allow stacks less than 2mb.
*/ */
size = VIPS_MAX( size, 2 * 1024 * 1024 ); size = VIPS_MAX( size, 2 * 1024 * 1024 );
if( pthread_attr_init( &attr ) || if( pthread_attr_init( &attr ) ||
pthread_attr_getstacksize( &attr, &cur_stack_size ) ) { pthread_attr_getstacksize( &attr, &cur_stack_size ) ) {
g_warning( "set_stacksize: unable to get stack size" ); g_warning( "set_stacksize: unable to get stack size" );
return; return;
} }
skipping to change at line 404 skipping to change at line 422
/* Called more than once, we succeeded, just return OK. /* Called more than once, we succeeded, just return OK.
*/ */
return( 0 ); return( 0 );
if( started ) if( started )
/* Recursive invocation, something has broken horribly. /* Recursive invocation, something has broken horribly.
* Hopefully the first init will handle it. * Hopefully the first init will handle it.
*/ */
return( 0 ); return( 0 );
started = TRUE; started = TRUE;
#ifdef OS_WIN32 #ifdef G_OS_WIN32
/* Windows has a limit of 512 files open at once for the fopen() family /* Windows has a limit of 512 files open at once for the fopen() family
* of functions, and 2048 for the _open() family. This raises the limit * of functions, and 2048 for the _open() family. This raises the limit
* of fopen() to the same level as _open(). * of fopen() to the same level as _open().
* *
* It will not go any higher than this, unfortunately. * It will not go any higher than this, unfortunately.
*/ */
(void) _setmaxstdio( 2048 ); (void) _setmaxstdio( 2048 );
#endif /*OS_WIN32*/ #endif /*G_OS_WIN32*/
#ifdef HAVE_TYPE_INIT
/* Before glib 2.36 you have to call this on startup.
*/
g_type_init();
#endif /*HAVE_TYPE_INIT*/
/* Older glibs need this.
*/
#ifndef HAVE_THREAD_NEW
if( !g_thread_supported() )
g_thread_init( NULL );
#endif /*HAVE_THREAD_NEW*/
vips__threadpool_init(); vips__threadpool_init();
vips__buffer_init(); vips__buffer_init();
vips__meta_init(); vips__meta_init();
/* This does an unsynchronised static hash table init on first call -- /* This does an unsynchronised static hash table init on first call --
* we have to make sure we do this single-threaded. See: * we have to make sure we do this single-threaded. See:
* https://github.com/openslide/openslide/issues/161 * https://github.com/openslide/openslide/issues/161
*/ */
#if !GLIB_CHECK_VERSION( 2, 48, 1 ) #if !GLIB_CHECK_VERSION( 2, 48, 1 )
(void) g_get_language_names(); (void) g_get_language_names();
#endif #endif
if( !vips__global_lock ) if( !vips__global_lock )
vips__global_lock = vips_g_mutex_new(); vips__global_lock = vips_g_mutex_new();
if( !vips__global_timer ) if( !vips__global_timer )
vips__global_timer = g_timer_new(); vips__global_timer = g_timer_new();
VIPS_SETSTR( vips__argv0, argv0 ); VIPS_SETSTR( vips__argv0, argv0 );
vips__prgname = g_path_get_basename( argv0 );
if( argv0 ) {
char *prgname;
prgname = g_path_get_basename( argv0 );
g_set_prgname( prgname );
g_free( prgname );
}
vips__thread_profile_attach( "main" ); vips__thread_profile_attach( "main" );
/* We can't do VIPS_GATE_START() until command-line processing /* We can't do VIPS_GATE_START() until command-line processing
* happens, since vips__thread_profile may not be set yet. Call * happens, since vips__thread_profile may not be set yet. Call
* directly. * directly.
*/ */
vips__thread_gate_start( "init: main" ); vips__thread_gate_start( "init: main" );
vips__thread_gate_start( "init: startup" ); vips__thread_gate_start( "init: startup" );
skipping to change at line 477 skipping to change at line 475
!(libdir = vips_guess_libdir( argv0, "VIPSHOME" )) ) !(libdir = vips_guess_libdir( argv0, "VIPSHOME" )) )
return( -1 ); return( -1 );
/* Get i18n .mo files from $VIPSHOME/share/locale/. /* Get i18n .mo files from $VIPSHOME/share/locale/.
*/ */
locale = g_build_filename( prefix, "share", "locale", NULL ); locale = g_build_filename( prefix, "share", "locale", NULL );
bindtextdomain( GETTEXT_PACKAGE, locale ); bindtextdomain( GETTEXT_PACKAGE, locale );
g_free( locale ); g_free( locale );
bind_textdomain_codeset( GETTEXT_PACKAGE, "UTF-8" ); bind_textdomain_codeset( GETTEXT_PACKAGE, "UTF-8" );
if( g_getenv( "VIPS_INFO" )
#if ENABLE_DEPRECATED #if ENABLE_DEPRECATED
if( g_getenv( "VIPS_INFO" ) || || g_getenv( "IM_INFO" )
g_getenv( "IM_INFO" ) )
#else
if( g_getenv( "VIPS_INFO" ) )
#endif #endif
)
vips_verbose(); vips_verbose();
if( g_getenv( "VIPS_PROFILE" ) ) if( g_getenv( "VIPS_PROFILE" ) )
vips_profile_set( TRUE ); vips_profile_set( TRUE );
if( g_getenv( "VIPS_LEAK" ) ) if( g_getenv( "VIPS_LEAK" ) )
vips_leak_set( TRUE ); vips_leak_set( TRUE );
if( g_getenv( "VIPS_TRACE" ) ) if( g_getenv( "VIPS_TRACE" ) )
vips_cache_set_trace( TRUE ); vips_cache_set_trace( TRUE );
if( g_getenv( "VIPS_PIPE_READ_LIMIT" ) ) if( g_getenv( "VIPS_PIPE_READ_LIMIT" ) )
vips_pipe_read_limit = vips_pipe_read_limit =
g_ascii_strtoll( g_getenv( "VIPS_PIPE_READ_LIMIT" ), g_ascii_strtoll( g_getenv( "VIPS_PIPE_READ_LIMIT" ),
skipping to change at line 539 skipping to change at line 536
vips_resample_operation_init(); vips_resample_operation_init();
vips_colour_operation_init(); vips_colour_operation_init();
vips_histogram_operation_init(); vips_histogram_operation_init();
vips_convolution_operation_init(); vips_convolution_operation_init();
vips_freqfilt_operation_init(); vips_freqfilt_operation_init();
vips_morphology_operation_init(); vips_morphology_operation_init();
vips_draw_operation_init(); vips_draw_operation_init();
vips_mosaicing_operation_init(); vips_mosaicing_operation_init();
vips_g_input_stream_get_type(); vips_g_input_stream_get_type();
/* Load any vips8 plugins from the vips libdir. Keep going, even if /* Load any vips8 modules from the vips libdir. Keep going, even if
* some plugins fail to load. * some modules fail to load.
*/ */
(void) vips_load_plugins( "%s/vips-plugins-%d.%d", (void) vips_load_plugins( "%s/vips-modules-%d.%d",
libdir, VIPS_MAJOR_VERSION, VIPS_MINOR_VERSION ); libdir, VIPS_MAJOR_VERSION, VIPS_MINOR_VERSION );
#if ENABLE_DEPRECATED #if ENABLE_DEPRECATED
/* Load any vips8 plugins from the vips libdir.
*/
(void) vips_load_plugins( "%s/vips-plugins-%d.%d",
libdir, VIPS_MAJOR_VERSION, VIPS_MINOR_VERSION );
/* Load up any vips7 plugins in the vips libdir. We don't error on /* Load up any vips7 plugins in the vips libdir. We don't error on
* failure, it's too annoying to have VIPS refuse to start because of * failure, it's too annoying to have VIPS refuse to start because of
* a broken plugin. * a broken plugin.
*/ */
if( im_load_plugins( "%s/vips-%d.%d", if( im_load_plugins( "%s/vips-%d.%d",
libdir, VIPS_MAJOR_VERSION, VIPS_MINOR_VERSION ) ) { libdir, VIPS_MAJOR_VERSION, VIPS_MINOR_VERSION ) ) {
g_warning( "%s", vips_error_buffer() ); g_warning( "%s", vips_error_buffer() );
vips_error_clear(); vips_error_clear();
} }
skipping to change at line 596 skipping to change at line 598
done = TRUE; done = TRUE;
/* If VIPS_WARNING is defined, suppress all warning messages from vips. /* If VIPS_WARNING is defined, suppress all warning messages from vips.
* *
* Libraries should not call g_log_set_handler(), it is * Libraries should not call g_log_set_handler(), it is
* supposed to be for the application layer, but this can be awkward to * supposed to be for the application layer, but this can be awkward to
* set up if you are using libvips from something like Ruby. Allow this * set up if you are using libvips from something like Ruby. Allow this
* env var hack as a workaround. * env var hack as a workaround.
*/ */
if( g_getenv( "VIPS_WARNING" )
#if ENABLE_DEPRECATED #if ENABLE_DEPRECATED
if( g_getenv( "VIPS_WARNING" ) || || g_getenv( "IM_WARNING" )
g_getenv( "IM_WARNING" ) )
#else
if( g_getenv( "VIPS_WARNING" ) )
#endif #endif
)
g_log_set_handler( G_LOG_DOMAIN, G_LOG_LEVEL_WARNING, g_log_set_handler( G_LOG_DOMAIN, G_LOG_LEVEL_WARNING,
empty_log_handler, NULL ); empty_log_handler, NULL );
#if !GLIB_CHECK_VERSION( 2, 31, 0 )
/* Older glibs can sometimes show G_LOG_LEVEL_{INFO,DEBUG} messages.
* Block them ourselves. We test the env var inside the handler since
* vips_verbose() can be toggled at runtime.
*
* Again, we should not call g_log_set_handler(), but this is the only
* convenient way to fix this behaviour.
*/
g_log_set_handler( G_LOG_DOMAIN, G_LOG_LEVEL_INFO | G_LOG_LEVEL_DEBUG,
default_log_handler, NULL );
#endif /*!GLIB_CHECK_VERSION( 2, 31, 0 )*/
/* Set a minimum stacksize, if we can. /* Set a minimum stacksize, if we can.
*/ */
if( (vips_min_stack_size = g_getenv( "VIPS_MIN_STACK_SIZE" )) ) if( (vips_min_stack_size = g_getenv( "VIPS_MIN_STACK_SIZE" )) )
(void) set_stacksize( vips__parse_size( vips_min_stack_size ) ); (void) set_stacksize( vips__parse_size( vips_min_stack_size ) );
vips__thread_gate_stop( "init: startup" ); vips__thread_gate_stop( "init: startup" );
return( 0 ); return( 0 );
} }
skipping to change at line 640 skipping to change at line 629
vips_check_init( void ) vips_check_init( void )
{ {
/* Pass in a nonsense name for argv0 ... this init path is only here /* Pass in a nonsense name for argv0 ... this init path is only here
* for old programs which are missing an vips_init() call. We need * for old programs which are missing an vips_init() call. We need
* i18n set up before we can translate. * i18n set up before we can translate.
*/ */
if( vips_init( "vips" ) ) if( vips_init( "vips" ) )
vips_error_clear(); vips_error_clear();
} }
static void static int
vips_leak( void ) vips_leak( void )
{ {
char txt[1024]; char txt[1024];
VipsBuf buf = VIPS_BUF_STATIC( txt ); VipsBuf buf = VIPS_BUF_STATIC( txt );
int n_leaks;
n_leaks = 0;
vips_object_print_all(); n_leaks += vips__object_leak();
n_leaks += vips__type_leak();
n_leaks += vips_tracked_get_allocs();
n_leaks += vips_tracked_get_mem();
n_leaks += vips_tracked_get_files();
if( vips_tracked_get_allocs() || if( vips_tracked_get_allocs() ||
vips_tracked_get_mem() || vips_tracked_get_mem() ||
vips_tracked_get_files() ) { vips_tracked_get_files() ) {
vips_buf_appendf( &buf, "memory: %d allocations, %zd bytes\n", vips_buf_appendf( &buf, "memory: %d allocations, %zd bytes\n",
vips_tracked_get_allocs(), vips_tracked_get_mem() ); vips_tracked_get_allocs(), vips_tracked_get_mem() );
vips_buf_appendf( &buf, "files: %d open\n", vips_buf_appendf( &buf, "files: %d open\n",
vips_tracked_get_files() ); vips_tracked_get_files() );
} }
vips_buf_appendf( &buf, "memory: high-water mark " ); vips_buf_appendf( &buf, "memory: high-water mark " );
vips_buf_append_size( &buf, vips_tracked_get_mem_highwater() ); vips_buf_append_size( &buf, vips_tracked_get_mem_highwater() );
vips_buf_appends( &buf, "\n" ); vips_buf_appends( &buf, "\n" );
if( strlen( vips_error_buffer() ) > 0 ) if( strlen( vips_error_buffer() ) > 0 ) {
vips_buf_appendf( &buf, "error buffer: %s", vips_buf_appendf( &buf, "error buffer: %s",
vips_error_buffer() ); vips_error_buffer() );
n_leaks += strlen( vips_error_buffer() );
if( vips__n_active_threads > 0 ) }
vips_buf_appendf( &buf, "threads: %d not joined\n",
vips__n_active_threads );
fprintf( stderr, "%s", vips_buf_all( &buf ) ); fprintf( stderr, "%s", vips_buf_all( &buf ) );
vips__print_renders(); n_leaks += vips__print_renders();
#ifdef DEBUG #ifdef DEBUG
vips_buffer_dump_all(); vips_buffer_dump_all();
#endif /*DEBUG*/ #endif /*DEBUG*/
return( n_leaks );
} }
/** /**
* vips_thread_shutdown: * vips_thread_shutdown:
* *
* Free any thread-private data and flush any profiling information. * Free any thread-private data and flush any profiling information.
* *
* This function needs to be called when a thread that has been using vips * This function needs to be called when a thread that has been using vips
* exits. It is called for you by vips_shutdown() and for any threads created * exits. It is called for you by vips_shutdown() and for any threads created
* by vips_g_thread_new(). * within the #VipsThreadPool.
* *
* You will need to call it from threads created in * You will need to call it from threads created in
* other ways or there will be memory leaks. If you do not call it, vips * other ways or there will be memory leaks. If you do not call it, vips
* will generate a warning message. * will generate a warning message.
* *
* It may be called many times, and you can continue using vips after * It may be called many times, and you can continue using vips after
* calling it. Calling it too often will reduce performance. * calling it. Calling it too often will reduce performance.
*/ */
void void
vips_thread_shutdown( void ) vips_thread_shutdown( void )
{ {
vips__thread_profile_detach(); vips__thread_profile_detach();
vips__buffer_shutdown();
} }
/** /**
* vips_shutdown: * vips_shutdown:
* *
* Call this to drop caches and close plugins. Run with "--vips-leak" to do * Call this to drop caches and close plugins. Run with "--vips-leak" to do
* a leak check too. * a leak check too.
* *
* You may call VIPS_INIT() many times and vips_shutdown() many times, but you * You may call VIPS_INIT() many times and vips_shutdown() many times, but you
* must not call VIPS_INIT() after vips_shutdown(). In other words, you cannot * must not call VIPS_INIT() after vips_shutdown(). In other words, you cannot
skipping to change at line 739 skipping to change at line 736
if( !done ) if( !done )
vips__thread_gate_stop( "init: main" ); vips__thread_gate_stop( "init: main" );
} }
vips__render_shutdown(); vips__render_shutdown();
vips_thread_shutdown(); vips_thread_shutdown();
vips__thread_profile_stop(); vips__thread_profile_stop();
vips__threadpool_shutdown();
#ifdef HAVE_GSF #ifdef HAVE_GSF
gsf_shutdown(); gsf_shutdown();
#endif /*HAVE_GSF*/ #endif /*HAVE_GSF*/
/* In dev releases, always show leaks. But not more than once, it's /* In dev releases, always show leaks. But not more than once, it's
* annoying. * annoying.
*/ */
#ifndef DEBUG_LEAK #ifndef DEBUG_LEAK
if( vips__leak ) if( vips__leak )
#endif /*DEBUG_LEAK*/ #endif /*DEBUG_LEAK*/
{ {
static gboolean done = FALSE; static gboolean done = FALSE;
if( !done ) if( !done &&
vips_leak(); vips_leak() )
exit( 1 );
done = TRUE; done = TRUE;
} }
VIPS_FREE( vips__argv0 );
VIPS_FREE( vips__prgname );
VIPS_FREEF( vips_g_mutex_free, vips__global_lock );
VIPS_FREEF( g_timer_destroy, vips__global_timer );
} }
const char * const char *
vips__gettext( const char *msgid ) vips__gettext( const char *msgid )
{ {
vips_check_init(); vips_check_init();
return( dgettext( GETTEXT_PACKAGE, msgid ) ); return( dgettext( GETTEXT_PACKAGE, msgid ) );
} }
skipping to change at line 1053 skipping to change at line 1058
char *prefix; char *prefix;
char full_path[VIPS_PATH_MAX]; char full_path[VIPS_PATH_MAX];
if( !path ) if( !path )
return( NULL ); return( NULL );
#ifdef DEBUG #ifdef DEBUG
printf( "vips_guess_prefix: g_getenv( \"PATH\" ) == \"%s\"\n", path ); printf( "vips_guess_prefix: g_getenv( \"PATH\" ) == \"%s\"\n", path );
#endif /*DEBUG*/ #endif /*DEBUG*/
#ifdef OS_WIN32 #ifdef G_OS_WIN32
{ {
char *dir; char *dir;
/* Windows always searches '.' first, so prepend cwd to path. /* Windows always searches '.' first, so prepend cwd to path.
*/ */
dir = g_get_current_dir(); dir = g_get_current_dir();
vips_snprintf( full_path, VIPS_PATH_MAX, vips_snprintf( full_path, VIPS_PATH_MAX,
"%s" G_SEARCHPATH_SEPARATOR_S "%s", dir, path ); "%s" G_SEARCHPATH_SEPARATOR_S "%s", dir, path );
g_free( dir ); g_free( dir );
} }
#else /*!OS_WIN32*/ #else /*!G_OS_WIN32*/
vips_strncpy( full_path, path, VIPS_PATH_MAX ); vips_strncpy( full_path, path, VIPS_PATH_MAX );
#endif /*OS_WIN32*/ #endif /*G_OS_WIN32*/
if( (prefix = scan_path( full_path, name )) ) if( (prefix = scan_path( full_path, name )) )
return( prefix ); return( prefix );
return( NULL ); return( NULL );
} }
/* Guess a value for the install PREFIX. /* Guess a value for the install PREFIX.
*/ */
static const char * static const char *
skipping to change at line 1173 skipping to change at line 1178
/* Already set? /* Already set?
*/ */
if( (prefix = g_getenv( env_name )) ) { if( (prefix = g_getenv( env_name )) ) {
#ifdef DEBUG #ifdef DEBUG
printf( "vips_guess_prefix: found \"%s\" in environment\n", printf( "vips_guess_prefix: found \"%s\" in environment\n",
prefix ); prefix );
#endif /*DEBUG*/ #endif /*DEBUG*/
return( prefix ); return( prefix );
} }
#ifdef OS_WIN32 #ifdef G_OS_WIN32
prefix = vips__windows_prefix(); prefix = vips__windows_prefix();
#else #else /*!G_OS_WIN32*/
{ {
char *basename; char *basename;
basename = g_path_get_basename( argv0 ); basename = g_path_get_basename( argv0 );
prefix = guess_prefix( argv0, basename ); prefix = guess_prefix( argv0, basename );
g_free( basename ); g_free( basename );
} }
#endif #endif /*G_OS_WIN32*/
g_setenv( env_name, prefix, TRUE ); g_setenv( env_name, prefix, TRUE );
return( prefix ); return( prefix );
} }
/** /**
* vips_guess_libdir: * vips_guess_libdir:
* @argv0: program name (typically argv[0]) * @argv0: program name (typically argv[0])
* @env_name: save prefix in this environment variable * @env_name: save prefix in this environment variable
 End of changes. 41 change blocks. 
86 lines changed or deleted 91 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)