From 32a1f952e85d5c8f2f2c19dffecc05b4ee8364b2 Mon Sep 17 00:00:00 2001 From: Warren Dukes Date: Sun, 6 Mar 2005 20:04:50 +0000 Subject: fix stateFile path getting garbled git-svn-id: https://svn.musicpd.org/mpd/trunk@3029 09075e82-0dd4-0310-85a5-a0d7c8717e4f --- src/directory.c | 4 ++-- src/path.c | 16 ++++++++-------- src/playlist.c | 46 ++++++++++++++++++++++++++++------------------ 3 files changed, 38 insertions(+), 28 deletions(-) diff --git a/src/directory.c b/src/directory.c index 3249d6382..694ffc08a 100644 --- a/src/directory.c +++ b/src/directory.c @@ -65,9 +65,9 @@ #define DIRECTORY_RETURN_UPDATE 1 #define DIRECTORY_RETURN_ERROR -1 -static Directory * mp3rootDirectory = NULL; +Directory * mp3rootDirectory = NULL; -static time_t directory_dbModTime = 0; +time_t directory_dbModTime = 0; volatile int directory_updatePid = 0; diff --git a/src/path.c b/src/path.c index c35be7f04..dec9844b6 100644 --- a/src/path.c +++ b/src/path.c @@ -116,15 +116,15 @@ static char * appendSlash(char ** path) { int len = strlen(temp); if(temp[len-1] != '/') { - temp = strdup(*path); + temp = malloc(len+2); + memset(temp, 0, len+2); + memcpy(temp, *path, len); + temp[len] = '/'; free(*path); - *path = malloc(len+2); - memset(*path, 0, len+2); - memcpy(*path, temp, len); - (*path)[len] = '/'; + *path = temp; } - return * path; + return temp; } void initPaths() { @@ -136,8 +136,8 @@ void initPaths() { char * originalLocale; DIR * dir; - musicDir = appendSlash(&musicParam->value); - playlistDir = appendSlash(&playlistParam->value); + musicDir = appendSlash(&(musicParam->value)); + playlistDir = appendSlash(&(playlistParam->value)); if((dir = opendir(playlistDir)) == NULL) { ERROR("cannot open %s \"%s\" (config line %i): %s\n", diff --git a/src/playlist.c b/src/playlist.c index d7a946e25..3a2bfcc78 100644 --- a/src/playlist.c +++ b/src/playlist.c @@ -88,12 +88,18 @@ static int playlist_noGoToNext = 0; static int playlist_saveAbsolutePaths = DEFAULT_PLAYLIST_SAVE_ABSOLUTE_PATHS; -static char * playlist_stateFile = NULL; - static void swapOrder(int a, int b); static int playPlaylistOrderNumber(FILE * fp, int orderNum); static void randomizeOrder(int start, int end); +static char * getStateFile() { + ConfigParam * param = parseConfigFilePath(CONF_STATE_FILE, 0); + + if(!param) return NULL; + + return param->value; +} + static void incrPlaylistVersion() { static unsigned long max = ((mpd_uint32)1<<31)-1; playlist.version++; @@ -179,8 +185,6 @@ void initPlaylist() { srandom(time(NULL)); - playlist_stateFile = parseConfigFilePath(CONF_STATE_FILE, 0); - for(i=0; i