#define config_LoadConfigFile(a,b) __config_LoadConfigFile(VLC_OBJECT(a),b)
int __config_LoadCmdLine ( vlc_object_t *, int *, const char *[], bool );
-char *config_GetHomeDir ( void );
+const char *config_GetHomeDir ( void );
char *config_GetCustomConfigFile( libvlc_int_t * );
int __config_LoadConfigFile( vlc_object_t *, const char * );
static const char *GetDir( bool b_appdata )
{
+ /* FIXME: a full memory page here - quite a waste... */
static char homedir[PATH_MAX] = "";
#if defined (WIN32)
/**
* Get the user's home directory
*/
-char *config_GetHomeDir( void )
+const char *config_GetHomeDir( void )
{
- return strdup (GetDir( false ));
+ return GetDir (false);
}
static char *config_GetFooDir (const char *xdg_name, const char *xdg_default)
{
char *psz_dir;
#if defined(WIN32) || defined(__APPLE__) || defined(SYS_BEOS)
- char *psz_parent = strdup (GetDir (true));
+ const char *psz_parent = GetDir (true);
if( asprintf( &psz_dir, "%s" DIR_SEP CONFIG_DIR, psz_parent ) == -1 )
psz_dir = NULL;
- free (psz_parent);
(void)xdg_name; (void)xdg_default;
#else
char var[sizeof ("XDG__HOME") + strlen (xdg_name)];
-
/* XDG Base Directory Specification - Version 0.6 */
snprintf (var, sizeof (var), "XDG_%s_HOME", xdg_name);
- char *psz_home = getenv( var );
- psz_home = psz_home ? FromLocaleDup( psz_home ) : NULL;
+
+ const char *psz_home = getenv (var);
+ psz_home = psz_home ? FromLocale (psz_home) : NULL;
if( psz_home )
{
if( asprintf( &psz_dir, "%s/vlc", psz_home ) == -1 )
psz_dir = NULL;
- goto out;
+ LocaleFree (psz_home);
+ return psz_dir;
}
/* Try HOME, then fallback to non-XDG dirs */
psz_home = config_GetHomeDir();
if( asprintf( &psz_dir, "%s/%s/vlc", psz_home, xdg_default ) == -1 )
psz_dir = NULL;
-
-out:
- free (psz_home);
#endif
return psz_dir;
}
/* Free module bank. It is refcounted, so we call this each time */
module_EndBank( p_libvlc );
- FREENULL( p_libvlc->psz_homedir );
FREENULL( priv->psz_configfile );
var_DelCallback( p_libvlc, "key-pressed", vlc_key_to_action,
p_libvlc->p_hotkeys );