path: allocate buffer in fs_charset conversion functions

Don't use fixed static buffers.  GLib allocates a new string for us
anyway, let's just return this one instead of copying it.
This commit is contained in:
Max Kellermann
2009-01-08 21:20:46 +01:00
parent f0980283bc
commit 5ed5aa99ac
6 changed files with 55 additions and 46 deletions

View File

@@ -37,7 +37,7 @@ static struct stored_playlist_info *
load_playlist_info(const char *parent_path_fs, const char *name_fs)
{
size_t name_length = strlen(name_fs);
char buffer[MPD_PATH_MAX], *path_fs, *name, *name_utf8;
char *path_fs, *name, *name_utf8;
int ret;
struct stat st;
struct stored_playlist_info *playlist;
@@ -60,13 +60,13 @@ load_playlist_info(const char *parent_path_fs, const char *name_fs)
name = g_strdup(name_fs);
name[name_length - sizeof(PLAYLIST_FILE_SUFFIX)] = 0;
name_utf8 = fs_charset_to_utf8(buffer, name);
name_utf8 = fs_charset_to_utf8(name);
g_free(name);
if (name_utf8 == NULL)
return NULL;
playlist = g_new(struct stored_playlist_info, 1);
playlist->name = g_strdup(name_utf8);
playlist->name = name_utf8;
playlist->mtime = st.st_mtime;
return playlist;
}