aboutsummaryrefslogtreecommitdiffstats
path: root/src/mapper.c
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2009-01-02 10:48:11 +0100
committerMax Kellermann <max@duempel.org>2009-01-02 10:48:11 +0100
commit72255d580e23405375562160bf05fb55d3248f39 (patch)
tree3730bdf7d0847b01f291c9ced0dc30856b45a26b /src/mapper.c
parentb2e3b644838bec1877bca9999569e0f82951ec1f (diff)
downloadmpd-72255d580e23405375562160bf05fb55d3248f39.tar.gz
mpd-72255d580e23405375562160bf05fb55d3248f39.tar.xz
mpd-72255d580e23405375562160bf05fb55d3248f39.zip
mapper: allocate the result of map_uri_fs(), map_directory_fs()
Don't use fixed stack buffers.
Diffstat (limited to 'src/mapper.c')
-rw-r--r--src/mapper.c29
1 files changed, 10 insertions, 19 deletions
diff --git a/src/mapper.c b/src/mapper.c
index 3777b7c62..6b0a7a449 100644
--- a/src/mapper.c
+++ b/src/mapper.c
@@ -89,53 +89,44 @@ void mapper_finish(void)
g_free(playlist_dir);
}
-static char *
-rmp2amp_r(char *dst, const char *rel_path)
-{
- pfx_dir(dst, rel_path, strlen(rel_path),
- (const char *)music_dir, music_dir_length);
- return dst;
-}
-
-const char *
-map_uri_fs(const char *uri, char *buffer)
+char *
+map_uri_fs(const char *uri)
{
assert(uri != NULL);
assert(*uri != '/');
- assert(buffer != NULL);
- return rmp2amp_r(buffer, utf8_to_fs_charset(buffer, uri));
+ return g_build_filename(music_dir, uri, NULL);
}
-const char *
-map_directory_fs(const struct directory *directory, char *buffer)
+char *
+map_directory_fs(const struct directory *directory)
{
const char *dirname = directory_get_path(directory);
if (isRootDirectory(dirname))
- return music_dir;
+ return g_strdup(music_dir);
- return map_uri_fs(dirname, buffer);
+ return map_uri_fs(dirname);
}
const char *
map_directory_child_fs(const struct directory *directory, const char *name,
char *buffer)
{
- char buffer2[MPD_PATH_MAX];
- const char *parent_fs;
+ char *parent_fs;
/* check for invalid or unauthorized base names */
if (*name == 0 || strchr(name, '/') != NULL ||
strcmp(name, ".") == 0 || strcmp(name, "..") == 0)
return NULL;
- parent_fs = map_directory_fs(directory, buffer2);
+ parent_fs = map_directory_fs(directory);
if (parent_fs == NULL)
return NULL;
name = utf8_to_fs_charset(buffer, name);
pfx_dir(buffer, name, strlen(name),
parent_fs, strlen(parent_fs));
+ g_free(parent_fs);
return buffer;
}