[vlc-devel] commit: No need to keep the config file around all the time ( Rémi Denis-Courmont )

git version control git at videolan.org
Wed May 6 19:27:12 CEST 2009


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Wed May  6 18:40:06 2009 +0300| [d6d444d2e4880e9a56cd390e92148c56dc5e7e10] | committer: Rémi Denis-Courmont 

No need to keep the config file around all the time

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=d6d444d2e4880e9a56cd390e92148c56dc5e7e10
---

 src/config/file.c |   36 +++++++++++++++++-------------------
 src/libvlc.c      |    8 --------
 src/libvlc.h      |    1 -
 3 files changed, 17 insertions(+), 28 deletions(-)

diff --git a/src/config/file.c b/src/config/file.c
index f170bbe..5dc5f2d 100644
--- a/src/config/file.c
+++ b/src/config/file.c
@@ -65,13 +65,12 @@ static char *config_GetConfigFile( void )
 
 static FILE *config_OpenConfigFile( vlc_object_t *p_obj, const char *mode )
 {
-    char *psz_filename = libvlc_priv (p_obj->p_libvlc)->psz_configfile;
+    char *psz_filename;
     FILE *p_stream;
 
+    psz_filename = config_GetCustomConfigFile( p_obj->p_libvlc );
     if( !psz_filename )
-    {
         psz_filename = config_GetConfigFile();
-    }
 
     msg_Dbg( p_obj, "opening config file (%s)", psz_filename );
 
@@ -121,11 +120,6 @@ static FILE *config_OpenConfigFile( vlc_object_t *p_obj, const char *mode )
         }
     }
 #endif
-    else if( p_stream != NULL )
-    {
-        libvlc_priv (p_obj->p_libvlc)->psz_configfile = psz_filename;
-    }
-
     return p_stream;
 }
 
@@ -391,6 +385,17 @@ config_Write (FILE *file, const char *type, const char *desc,
 }
 
 
+static int config_PrepareDir (vlc_object_t *obj)
+{
+    char *psz_configdir = config_GetUserConfDir ();
+    if (psz_configdir == NULL) /* XXX: This should never happen */
+        return -1;
+
+    int ret = config_CreateDir (obj, psz_configdir);
+    free (psz_configdir);
+    return ret;
+}
+
 /*****************************************************************************
  * config_SaveConfigFile: Save a module's config options.
  *****************************************************************************
@@ -425,18 +430,11 @@ static int SaveConfigFile( vlc_object_t *p_this, const char *psz_module_name,
     /* Acquire config file lock */
     vlc_mutex_lock( &priv->config_lock );
 
-    if( libvlc_priv (p_this->p_libvlc)->psz_configfile == NULL )
+    if( config_PrepareDir( p_this ) )
     {
-        char *psz_configdir = config_GetUserConfDir();
-        if( !psz_configdir ) /* XXX: This should never happen */
-        {
-            msg_Err( p_this, "no configuration directory defined" );
-            vlc_mutex_unlock( &priv->config_lock );
-            return -1;
-        }
-
-        config_CreateDir( p_this, psz_configdir );
-        free( psz_configdir );
+        msg_Err( p_this, "no configuration directory" );
+        vlc_mutex_unlock( &priv->config_lock );
+        return -1;
     }
 
     file = config_OpenConfigFile( p_this, "rt" );
diff --git a/src/libvlc.c b/src/libvlc.c
index d1aa5f8..3f441f6 100644
--- a/src/libvlc.c
+++ b/src/libvlc.c
@@ -358,9 +358,6 @@ int libvlc_InternalInit( libvlc_int_t *p_libvlc, int i_argc,
         i_ret = VLC_EEXITSUCCESS;
     }
 
-    /* Set the config file stuff */
-    priv->psz_configfile = config_GetCustomConfigFile( p_libvlc );
-
     /* Check for plugins cache options */
     bool b_cache_delete = config_GetInt( p_libvlc, "reset-plugins-cache" ) > 0;
 
@@ -431,7 +428,6 @@ int libvlc_InternalInit( libvlc_int_t *p_libvlc, int i_argc,
 
     if( b_exit )
     {
-        free( priv->psz_configfile );
         module_EndBank( p_libvlc, false );
         return i_ret;
     }
@@ -543,7 +539,6 @@ int libvlc_InternalInit( libvlc_int_t *p_libvlc, int i_argc,
 
     if( b_exit )
     {
-        free( priv->psz_configfile );
         module_EndBank( p_libvlc, true );
         return i_ret;
     }
@@ -571,7 +566,6 @@ int libvlc_InternalInit( libvlc_int_t *p_libvlc, int i_argc,
                  "that they are valid.\n" );
         PauseConsole();
 #endif
-        free( priv->psz_configfile );
         module_EndBank( p_libvlc, true );
         return VLC_EGENERIC;
     }
@@ -831,7 +825,6 @@ int libvlc_InternalInit( libvlc_int_t *p_libvlc, int i_argc,
             module_unneed( p_libvlc, priv->p_memcpy_module );
         }
         module_EndBank( p_libvlc, true );
-        free( priv->psz_configfile );
         return VLC_EGENERIC;
     }
     playlist_Activate( p_playlist );
@@ -1107,7 +1100,6 @@ void libvlc_InternalCleanup( libvlc_int_t *p_libvlc )
     /* Free module bank. It is refcounted, so we call this each time  */
     module_EndBank( p_libvlc, true );
 
-    FREENULL( priv->psz_configfile );
     var_DelCallback( p_libvlc, "key-pressed", vlc_key_to_action,
                      (void *)p_libvlc->p_hotkeys );
     free( (void *)p_libvlc->p_hotkeys );
diff --git a/src/libvlc.h b/src/libvlc.h
index 6ebecb1..07bc649 100644
--- a/src/libvlc.h
+++ b/src/libvlc.h
@@ -203,7 +203,6 @@ typedef struct libvlc_priv_t
 
     /* Configuration */
     vlc_mutex_t        config_lock; ///< config file lock
-    char *             psz_configfile;   ///< location of config file
 
     int                i_last_input_id ; ///< Last id of input item
 




More information about the vlc-devel mailing list