# include <dl.h>
# endif
#endif
+#ifdef HAVE_VALGRIND_VALGRIND_H
+# include <valgrind/valgrind.h>
+#endif
/*****************************************************************************
* Local prototypes
return 0;
}
-#if defined (RTLD_NOLOAD)
-/* Make sure libvlccore is in the global namespace */
-static void load_libvlccore( void )
-{
- if( !dlsym( RTLD_DEFAULT, "vlc_module_create" )
- && !dlopen( "libvlccore.so", RTLD_GLOBAL|RTLD_NOLOAD ) )
- fprintf( stderr, "ERROR: failed loading libvlccore\n" );
-}
-#endif
-
/**
* Load a dynamically linked library using a system dependent method.
*
}
#elif defined(HAVE_DL_DLOPEN)
-# if defined (RTLD_NOLOAD)
- static pthread_once_t once = PTHREAD_ONCE_INIT;
- pthread_once( &once, &load_libvlccore );
-# endif
# if defined (RTLD_NOW)
const int flags = RTLD_NOW;
const int flags = 0;
# endif
- handle = dlopen( psz_file, RTLD_NOW );
+ handle = dlopen( psz_file, flags );
if( handle == NULL )
{
msg_Warn( p_this, "cannot load module `%s' (%s)",
FreeLibrary( handle );
#elif defined(HAVE_DL_DLOPEN)
-# ifdef NDEBUG
- dlclose( handle );
-# else
- (void)handle;
+# ifdef HAVE_VALGRIND_VALGRIND_H
+ if( RUNNING_ON_VALGRIND > 0 )
+ return; /* do not dlclose() so that we get proper stack traces */
# endif
+ dlclose( handle );
#elif defined(HAVE_DL_SHL_LOAD)
shl_unload( handle );
}
#elif defined(HAVE_DL_WINDOWS) && defined(UNDER_CE)
- wchar_t wide[sizeof( psz_function ) + 1];
- size_t i;
+ wchar_t wide[strlen( psz_function ) + 1];
+ size_t i = 0;
do
wide[i] = psz_function[i]; /* UTF-16 <- ASCII */
while( psz_function[i++] );