aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2009-01-04 18:59:47 +0100
committerMax Kellermann <max@duempel.org>2009-01-04 18:59:47 +0100
commit923d2c966f2b8a3582156467ad46ea8d200b30f1 (patch)
tree647c54bf4194fbfb190ef24bdc199d7440e85f5a /src
parent8c5470a3db7f36cc50b8f5591c8b1f1410977581 (diff)
downloadmpd-923d2c966f2b8a3582156467ad46ea8d200b30f1.tar.gz
mpd-923d2c966f2b8a3582156467ad46ea8d200b30f1.tar.xz
mpd-923d2c966f2b8a3582156467ad46ea8d200b30f1.zip
mapper: allocate the result of map_fs_to_utf8()
Diffstat (limited to '')
-rw-r--r--src/mapper.c8
-rw-r--r--src/mapper.h8
-rw-r--r--src/stored_playlist.c5
3 files changed, 10 insertions, 11 deletions
diff --git a/src/mapper.c b/src/mapper.c
index bd19af615..06780588d 100644
--- a/src/mapper.c
+++ b/src/mapper.c
@@ -142,9 +142,11 @@ map_song_fs(const struct song *song)
return g_strdup(utf8_to_fs_charset(buffer, song->url));
}
-const char *
-map_fs_to_utf8(const char *path_fs, char *buffer)
+char *
+map_fs_to_utf8(const char *path_fs)
{
+ char buffer[MPD_PATH_MAX];
+
if (strncmp(path_fs, music_dir, music_dir_length) == 0 &&
path_fs[music_dir_length] == '/')
/* remove musicDir prefix */
@@ -153,7 +155,7 @@ map_fs_to_utf8(const char *path_fs, char *buffer)
/* not within musicDir */
return NULL;
- return fs_charset_to_utf8(buffer, path_fs);
+ return g_strdup(fs_charset_to_utf8(buffer, path_fs));
}
const char *
diff --git a/src/mapper.h b/src/mapper.h
index 74af0d133..d33a21bbf 100644
--- a/src/mapper.h
+++ b/src/mapper.h
@@ -44,7 +44,6 @@ map_uri_fs(const char *uri);
* Determines the file system path of a directory object.
*
* @param directory the directory object
- * @param a buffer which is MPD_PATH_MAX bytes long
* @return the path in file system encoding, or NULL if mapping failed
*/
char *
@@ -56,7 +55,6 @@ map_directory_fs(const struct directory *directory);
*
* @param directory the parent directory object
* @param name the child's name in UTF-8
- * @param a buffer which is MPD_PATH_MAX bytes long
* @return the path in file system encoding, or NULL if mapping failed
*/
char *
@@ -67,7 +65,6 @@ map_directory_child_fs(const struct directory *directory, const char *name);
* remote song.
*
* @param song the song object
- * @param a buffer which is MPD_PATH_MAX bytes long
* @return the path in file system encoding, or NULL if mapping failed
*/
char *
@@ -78,11 +75,10 @@ map_song_fs(const struct song *song);
* absolute) to a relative path in UTF-8 encoding.
*
* @param path_fs a path in file system encoding
- * @param buffer a buffer which is MPD_PATH_MAX bytes long
* @return the relative path in UTF-8, or NULL if mapping failed
*/
-const char *
-map_fs_to_utf8(const char *path_fs, char *buffer);
+char *
+map_fs_to_utf8(const char *path_fs);
/**
* Returns the playlist directory.
diff --git a/src/stored_playlist.c b/src/stored_playlist.c
index 25a4ce85a..fd2f6fc01 100644
--- a/src/stored_playlist.c
+++ b/src/stored_playlist.c
@@ -158,7 +158,6 @@ spl_load(const char *utf8path)
while (fgets(buffer, sizeof(buffer), file)) {
char *s = buffer;
- const char *path_utf8;
if (*s == PLAYLIST_COMMENT)
continue;
@@ -166,13 +165,15 @@ spl_load(const char *utf8path)
g_strchomp(buffer);
if (!uri_has_scheme(s)) {
+ char *path_utf8;
struct song *song;
- path_utf8 = map_fs_to_utf8(s, path_max_tmp);
+ path_utf8 = map_fs_to_utf8(s);
if (path_utf8 == NULL)
continue;
song = db_get_song(path_utf8);
+ g_free(path_utf8);
if (song == NULL)
continue;