+ free( psz_file );
+ }
+
+ /* Close the directory */
+ closedir( dir );
+}
+
+/*****************************************************************************
+ * AllocatePluginFile: load a module into memory and initialize it.
+ *****************************************************************************
+ * This function loads a dynamically loadable module and allocates a structure
+ * for its information data. The module can then be handled by module_Need,
+ * module_Unneed and HideModule. It can be removed by DeleteModule.
+ *****************************************************************************/
+static int AllocatePluginFile( vlc_object_t * p_this, char * psz_file )
+{
+ module_t * p_module;
+ module_handle_t handle;
+
+ /* Try to dynamically load the module. */
+ if( module_load( psz_file, &handle ) )
+ {
+ char psz_buffer[256];
+
+ /* The plugin module couldn't be opened */
+ msg_Warn( p_this, "cannot open `%s' (%s)",
+ psz_file, module_error( psz_buffer ) );
+ return -1;
+ }
+
+ /* Now that we have successfully loaded the module, we can
+ * allocate a structure for it */
+ p_module = vlc_object_create( p_this, VLC_OBJECT_MODULE );
+ if( p_module == NULL )
+ {
+ msg_Err( p_this, "out of memory" );
+ module_unload( handle );
+ return -1;
+ }
+
+ /* We need to fill these since they may be needed by CallEntry() */
+ p_module->psz_filename = psz_file;
+ p_module->handle = handle;
+ p_module->p_symbols = &p_this->p_vlc->p_module_bank->symbols;
+
+ /* Initialize the module: fill p_module->psz_object_name, default config */
+ if( CallEntry( p_module ) != 0 )
+ {
+ /* We couldn't call module_init() */
+ msg_Err( p_this, "failed calling entry point in `%s'", psz_file );
+ vlc_object_destroy( p_module );