]> git.sesse.net Git - vlc/blobdiff - src/modules/os.c
Remove unused scandir check
[vlc] / src / modules / os.c
index ca0e21415059808fecfc6681fcf10b54feb4eeee..58fef5189ce2f46899627c9232feaecb9b0223ef 100644 (file)
@@ -65,6 +65,9 @@
 #       include <dl.h>
 #   endif
 #endif
+#ifdef HAVE_VALGRIND_VALGRIND_H
+# include <valgrind/valgrind.h>
+#endif
 
 /*****************************************************************************
  * Local prototypes
@@ -129,16 +132,6 @@ int module_Call( vlc_object_t *obj, module_t *p_module )
     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.
  *
@@ -215,10 +208,6 @@ int module_Load( vlc_object_t *p_this, const char *psz_file,
     }
 
 #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;
@@ -228,7 +217,7 @@ int module_Load( vlc_object_t *p_this, const char *psz_file,
     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)",
@@ -274,11 +263,11 @@ void module_Unload( module_handle_t handle )
     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 );
@@ -321,8 +310,8 @@ static void *module_Lookup( module_handle_t handle, const char *psz_function )
     }
 
 #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++] );