diff --git a/src/fs/AllocatedPath.cxx b/src/fs/AllocatedPath.cxx index 65dcff56f..bd026db74 100644 --- a/src/fs/AllocatedPath.cxx +++ b/src/fs/AllocatedPath.cxx @@ -24,21 +24,6 @@ #include "util/Error.hxx" #include "Compiler.h" -#ifdef HAVE_GLIB -#include -#endif - -#include - -#ifdef HAVE_GLIB - -inline AllocatedPath::AllocatedPath(Donate, pointer _value) - :value(_value) { - g_free(_value); -} - -#endif - /* no inlining, please */ AllocatedPath::~AllocatedPath() {} @@ -46,11 +31,7 @@ AllocatedPath AllocatedPath::FromUTF8(const char *path_utf8) { #ifdef HAVE_FS_CHARSET - char *path = ::PathFromUTF8(path_utf8); - if (path == nullptr) - return AllocatedPath::Null(); - - return AllocatedPath(Donate(), path); + return AllocatedPath(::PathFromUTF8(path_utf8)); #else return FromFS(path_utf8); #endif diff --git a/src/fs/AllocatedPath.hxx b/src/fs/AllocatedPath.hxx index c345470c8..73b6891ad 100644 --- a/src/fs/AllocatedPath.hxx +++ b/src/fs/AllocatedPath.hxx @@ -44,13 +44,6 @@ class AllocatedPath { string value; - struct Donate {}; - - /** - * Donate the allocated pointer to a new #AllocatedPath object. - */ - AllocatedPath(Donate, pointer _value); - AllocatedPath(const_pointer _value):value(_value) {} AllocatedPath(string &&_value):value(std::move(_value)) {} diff --git a/src/fs/Charset.cxx b/src/fs/Charset.cxx index c98170c24..fb7313a35 100644 --- a/src/fs/Charset.cxx +++ b/src/fs/Charset.cxx @@ -157,13 +157,13 @@ PathToUTF8(const char *path_fs) #ifdef HAVE_FS_CHARSET -char * +std::string PathFromUTF8(const char *path_utf8) { assert(path_utf8 != nullptr); if (fs_charset.empty()) - return g_strdup(path_utf8); + return path_utf8; return g_convert(path_utf8, -1, fs_charset.c_str(), "utf-8", diff --git a/src/fs/Charset.hxx b/src/fs/Charset.hxx index 7a5193576..80f510ce0 100644 --- a/src/fs/Charset.hxx +++ b/src/fs/Charset.hxx @@ -52,8 +52,12 @@ gcc_pure gcc_nonnull_all std::string PathToUTF8(const char *path_fs); -gcc_malloc gcc_nonnull_all -char * +/** + * Convert the path from UTF-8. + * Returns empty string on error. + */ +gcc_pure gcc_nonnull_all +std::string PathFromUTF8(const char *path_utf8); #endif