[vlc-devel] commit: Use config_GetCacheDir internally ( Rémi Denis-Courmont )

git version control git at videolan.org
Tue May 6 22:14:38 CEST 2008


vlc | branch: master | Rémi Denis-Courmont <rem at videolan.org> | Tue May  6 22:56:57 2008 +0300| [75c438d3302e2a816a473576a35e17989d05a42c]

Use config_GetCacheDir internally

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

 src/input/meta.c    |   10 +++++-----
 src/libvlc-common.c |    2 --
 src/libvlc.h        |    1 -
 src/modules/cache.c |    9 ++++-----
 4 files changed, 9 insertions(+), 13 deletions(-)

diff --git a/src/input/meta.c b/src/input/meta.c
index 7abd04f..0447fad 100644
--- a/src/input/meta.c
+++ b/src/input/meta.c
@@ -239,15 +239,15 @@ static void __ArtCacheGetDirPath( vlc_object_t *p_obj,
                                   const char *psz_title,
                                   const char *psz_artist, const char *psz_album )
 {
+   char *psz_cachedir = config_GetCacheDir();
+
     if( !EMPTY_STR(psz_artist) && !EMPTY_STR(psz_album) )
     {
         char * psz_album_sanitized = ArtCacheGetSanitizedFileName( psz_album );
         char * psz_artist_sanitized = ArtCacheGetSanitizedFileName( psz_artist );
-
         snprintf( psz_dir, PATH_MAX, "%s" DIR_SEP
                   "art" DIR_SEP "artistalbum" DIR_SEP "%s" DIR_SEP "%s",
-                      libvlc_priv (p_obj->p_libvlc)->psz_cachedir,
-                      psz_artist_sanitized, psz_album_sanitized );
+                  psz_cachedir, psz_artist_sanitized, psz_album_sanitized );
         free( psz_album_sanitized );
         free( psz_artist_sanitized );
     }
@@ -256,10 +256,10 @@ static void __ArtCacheGetDirPath( vlc_object_t *p_obj,
         char * psz_title_sanitized = ArtCacheGetSanitizedFileName( psz_title );
         snprintf( psz_dir, PATH_MAX, "%s" DIR_SEP
                   "art" DIR_SEP "title" DIR_SEP "%s",
-                  libvlc_priv (p_obj->p_libvlc)->psz_cachedir,
-                  psz_title_sanitized );
+                  psz_cachedir, psz_title_sanitized );
         free( psz_title_sanitized );
     }
+    free( psz_cachedir );
 }
 
 
diff --git a/src/libvlc-common.c b/src/libvlc-common.c
index d7bea3b..7e08231 100644
--- a/src/libvlc-common.c
+++ b/src/libvlc-common.c
@@ -298,7 +298,6 @@ int libvlc_InternalInit( libvlc_int_t *p_libvlc, int i_argc,
     p_libvlc->psz_homedir    = config_GetHomeDir();
     priv->psz_configdir  = config_GetUserConfDir();
     priv->psz_datadir    = config_GetUserDataDir();
-    priv->psz_cachedir   = config_GetCacheDir();
     priv->psz_configfile = config_GetCustomConfigFile( p_libvlc );
 
     /* Check for plugins cache options */
@@ -1064,7 +1063,6 @@ int libvlc_InternalDestroy( libvlc_int_t *p_libvlc, bool b_release )
     FREENULL( p_libvlc->psz_homedir );
     free( priv->psz_configdir );
     free( priv->psz_datadir );
-    free( priv->psz_cachedir );
     FREENULL( priv->psz_configfile );
     var_DelCallback( p_libvlc, "key-pressed", vlc_key_to_action,
                      p_libvlc->p_hotkeys );
diff --git a/src/libvlc.h b/src/libvlc.h
index a6ba7be..f2466d5 100644
--- a/src/libvlc.h
+++ b/src/libvlc.h
@@ -213,7 +213,6 @@ typedef struct libvlc_priv_t
     char *             psz_configfile;   ///< location of config file
     char              *psz_configdir;    ///< user configuration directory
     char              *psz_datadir;      ///< user data directory
-    char              *psz_cachedir; ///< user cache directory
 
     /* There is no real reason to keep a list of items, but not to break
      * everything, let's keep it */
diff --git a/src/modules/cache.c b/src/modules/cache.c
index 67987d3..e15e890 100644
--- a/src/modules/cache.c
+++ b/src/modules/cache.c
@@ -96,7 +96,7 @@ static char * CacheName        ( void );
  *****************************************************************************/
 void CacheLoad( vlc_object_t *p_this )
 {
-    char *psz_filename, *psz_cachedir;
+    char *psz_filename, *psz_cachedir = config_GetCacheDir();
     FILE *file;
     int i, j, i_size, i_read;
     char p_cachestring[sizeof("cache " COPYRIGHT_MESSAGE)];
@@ -106,7 +106,6 @@ void CacheLoad( vlc_object_t *p_this )
     int32_t i_file_size, i_marker;
     libvlc_global_data_t *p_libvlc_global = vlc_global();
 
-    psz_cachedir = libvlc_priv(p_this->p_libvlc)->psz_cachedir;
     if( !psz_cachedir ) /* XXX: this should never happen */
     {
         msg_Err( p_this, "Unable to get cache directory" );
@@ -115,9 +114,9 @@ void CacheLoad( vlc_object_t *p_this )
 
     i_size = asprintf( &psz_filename, "%s"DIR_SEP"%s",
                        psz_cachedir, CacheName() );
+    free( psz_cachedir );
     if( i_size <= 0 )
     {
-        msg_Err( p_this, "out of memory" );
         return;
     }
 
@@ -454,14 +453,13 @@ void CacheSave( vlc_object_t *p_this )
         "# For information about cache directory tags, see:\r\n"
         "#   http://www.brynosaurus.com/cachedir/\r\n";
 
-    char *psz_cachedir;
+    char *psz_cachedir = config_GetCacheDir();
     FILE *file;
     int i, j, i_cache;
     module_cache_t **pp_cache;
     uint32_t i_file_size = 0;
     libvlc_global_data_t *p_libvlc_global = vlc_global();
 
-    psz_cachedir = libvlc_priv(p_this->p_libvlc)->psz_cachedir;
     if( !psz_cachedir ) /* XXX: this should never happen */
     {
         msg_Err( p_this, "unable to get cache directory" );
@@ -483,6 +481,7 @@ void CacheSave( vlc_object_t *p_this )
 
     snprintf( psz_filename, sizeof( psz_filename ),
               "%s"DIR_SEP"%s", psz_cachedir, CacheName() );
+    free( psz_cachedir );
     msg_Dbg( p_this, "writing plugins cache %s", psz_filename );
 
     file = utf8_fopen( psz_filename, "wb" );




More information about the vlc-devel mailing list