X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=src%2Fmodules%2Fcache.c;h=25b06050ca5a6914b463ad0472ef2521fb665282;hb=0c48d1cbac8288ba3a1a96f298a89f22668d4de5;hp=afda6074da84f0016d0ad2de83733d9c9d7b057e;hpb=7eba9008c5a57a90048772adb5e37be4327d309a;p=vlc diff --git a/src/modules/cache.c b/src/modules/cache.c index afda6074da..25b06050ca 100644 --- a/src/modules/cache.c +++ b/src/modules/cache.c @@ -24,12 +24,17 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. *****************************************************************************/ -#include +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + +#include #include "libvlc.h" #include /* free(), strtol() */ #include /* sprintf() */ #include /* strdup() */ +#include #ifdef HAVE_SYS_TYPES_H # include @@ -63,7 +68,7 @@ # endif #endif -#include "config/config.h" +#include "config/configuration.h" #include "vlc_charset.h" @@ -92,7 +97,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)]; @@ -102,7 +107,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 = p_this->p_libvlc->psz_cachedir; if( !psz_cachedir ) /* XXX: this should never happen */ { msg_Err( p_this, "Unable to get cache directory" ); @@ -111,9 +115,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; } @@ -254,13 +258,14 @@ void CacheLoad( vlc_object_t *p_this ) LOAD_IMMEDIATE( pp_cache[i]->i_time ); LOAD_IMMEDIATE( pp_cache[i]->i_size ); LOAD_IMMEDIATE( pp_cache[i]->b_junk ); - pp_cache[i]->b_used = VLC_FALSE; + pp_cache[i]->b_used = false; if( pp_cache[i]->b_junk ) continue; pp_cache[i]->p_module = vlc_module_create( p_this ); /* Load additional infos */ + free( pp_cache[i]->p_module->psz_object_name ); LOAD_STRING( pp_cache[i]->p_module->psz_object_name ); LOAD_STRING( pp_cache[i]->p_module->psz_shortname ); LOAD_STRING( pp_cache[i]->p_module->psz_longname ); @@ -287,6 +292,7 @@ void CacheLoad( vlc_object_t *p_this ) while( i_submodules-- ) { module_t *p_module = vlc_submodule_create( pp_cache[i]->p_module ); + free( p_module->psz_object_name ); LOAD_STRING( p_module->psz_object_name ); LOAD_STRING( p_module->psz_shortname ); LOAD_STRING( p_module->psz_longname ); @@ -352,7 +358,8 @@ static int CacheLoadConfig( module_t *p_module, FILE *file ) LOAD_STRING( p_module->p_config[i].psz_name ); LOAD_STRING( p_module->p_config[i].psz_text ); LOAD_STRING( p_module->p_config[i].psz_longtext ); - LOAD_STRING( p_module->p_config[i].psz_current ); + LOAD_STRING( p_module->p_config[i].psz_oldname ); + LOAD_IMMEDIATE( p_module->p_config[i].b_removed ); if (IsConfigStringType (p_module->p_config[i].i_type)) { @@ -370,9 +377,9 @@ static int CacheLoadConfig( module_t *p_module, FILE *file ) sizeof (p_module->p_config[i].saved)); } - p_module->p_config[i].b_dirty = VLC_FALSE; + p_module->p_config[i].b_dirty = false; - p_module->p_config[i].p_lock = &p_module->object_lock; + p_module->p_config[i].p_lock = &(vlc_internals(p_module)->lock); if( p_module->p_config[i].i_list ) { @@ -447,14 +454,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 = p_this->p_libvlc->psz_cachedir; if( !psz_cachedir ) /* XXX: this should never happen */ { msg_Err( p_this, "unable to get cache directory" ); @@ -476,6 +482,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" ); @@ -556,14 +563,14 @@ void CacheSave( vlc_object_t *p_this ) SAVE_STRING( pp_cache[i]->p_module->psz_filename ); - i_submodule = pp_cache[i]->p_module->i_children; + i_submodule = vlc_internals( pp_cache[i]->p_module )->i_children; SAVE_IMMEDIATE( i_submodule ); for( i_submodule = 0; - i_submodule < (unsigned)pp_cache[i]->p_module->i_children; + i_submodule < (unsigned)vlc_internals( pp_cache[i]->p_module)->i_children; i_submodule++ ) { module_t *p_module = - (module_t *)pp_cache[i]->p_module->pp_children[i_submodule]; + (module_t *)vlc_internals( pp_cache[i]->p_module )->pp_children[i_submodule]; SAVE_STRING( p_module->psz_object_name ); SAVE_STRING( p_module->psz_shortname ); @@ -617,7 +624,9 @@ static int CacheSaveConfig( module_t *p_module, FILE *file ) SAVE_STRING( p_module->p_config[i].psz_name ); SAVE_STRING( p_module->p_config[i].psz_text ); SAVE_STRING( p_module->p_config[i].psz_longtext ); - SAVE_STRING( p_module->p_config[i].psz_current ); + SAVE_STRING( p_module->p_config[i].psz_oldname ); + SAVE_IMMEDIATE( p_module->p_config[i].b_removed ); + if (IsConfigStringType (p_module->p_config[i].i_type)) SAVE_STRING( p_module->p_config[i].orig.psz ); @@ -678,22 +687,22 @@ void CacheMerge( vlc_object_t *p_this, module_t *p_cache, module_t *p_module ) p_cache->pf_deactivate = p_module->pf_deactivate; p_cache->handle = p_module->handle; - for( i_submodule = 0; i_submodule < p_module->i_children; i_submodule++ ) + for( i_submodule = 0; i_submodule < vlc_internals( p_module )->i_children; i_submodule++ ) { - module_t *p_child = (module_t*)p_module->pp_children[i_submodule]; - module_t *p_cchild = (module_t*)p_cache->pp_children[i_submodule]; + module_t *p_child = (module_t*)vlc_internals( p_module )->pp_children[i_submodule]; + module_t *p_cchild = (module_t*)vlc_internals( p_cache )->pp_children[i_submodule]; p_cchild->pf_activate = p_child->pf_activate; p_cchild->pf_deactivate = p_child->pf_deactivate; } - p_cache->b_loaded = VLC_TRUE; - p_module->b_loaded = VLC_FALSE; + p_cache->b_loaded = true; + p_module->b_loaded = false; } /***************************************************************************** * CacheFind: finds the cache entry corresponding to a file *****************************************************************************/ -module_cache_t *CacheFind( vlc_object_t *p_this, const char *psz_file, +module_cache_t *CacheFind( const char *psz_file, int64_t i_time, int64_t i_size ) { module_cache_t **pp_cache;