Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
mpd
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Иван Мажукин
mpd
Commits
4f80a129
Commit
4f80a129
authored
Nov 30, 2014
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fs/Charset: return std::string from PathFromUTF8()
Don't expose pointer that requires the caller to invoke g_free(), because that's GLib-only.
parent
6987f2ba
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
9 additions
and
31 deletions
+9
-31
AllocatedPath.cxx
src/fs/AllocatedPath.cxx
+1
-20
AllocatedPath.hxx
src/fs/AllocatedPath.hxx
+0
-7
Charset.cxx
src/fs/Charset.cxx
+2
-2
Charset.hxx
src/fs/Charset.hxx
+6
-2
No files found.
src/fs/AllocatedPath.cxx
View file @
4f80a129
...
@@ -24,21 +24,6 @@
...
@@ -24,21 +24,6 @@
#include "util/Error.hxx"
#include "util/Error.hxx"
#include "Compiler.h"
#include "Compiler.h"
#ifdef HAVE_GLIB
#include <glib.h>
#endif
#include <string.h>
#ifdef HAVE_GLIB
inline
AllocatedPath
::
AllocatedPath
(
Donate
,
pointer
_value
)
:
value
(
_value
)
{
g_free
(
_value
);
}
#endif
/* no inlining, please */
/* no inlining, please */
AllocatedPath
::~
AllocatedPath
()
{}
AllocatedPath
::~
AllocatedPath
()
{}
...
@@ -46,11 +31,7 @@ AllocatedPath
...
@@ -46,11 +31,7 @@ AllocatedPath
AllocatedPath
::
FromUTF8
(
const
char
*
path_utf8
)
AllocatedPath
::
FromUTF8
(
const
char
*
path_utf8
)
{
{
#ifdef HAVE_FS_CHARSET
#ifdef HAVE_FS_CHARSET
char
*
path
=
::
PathFromUTF8
(
path_utf8
);
return
AllocatedPath
(
::
PathFromUTF8
(
path_utf8
));
if
(
path
==
nullptr
)
return
AllocatedPath
::
Null
();
return
AllocatedPath
(
Donate
(),
path
);
#else
#else
return
FromFS
(
path_utf8
);
return
FromFS
(
path_utf8
);
#endif
#endif
...
...
src/fs/AllocatedPath.hxx
View file @
4f80a129
...
@@ -44,13 +44,6 @@ class AllocatedPath {
...
@@ -44,13 +44,6 @@ class AllocatedPath {
string
value
;
string
value
;
struct
Donate
{};
/**
* Donate the allocated pointer to a new #AllocatedPath object.
*/
AllocatedPath
(
Donate
,
pointer
_value
);
AllocatedPath
(
const_pointer
_value
)
:
value
(
_value
)
{}
AllocatedPath
(
const_pointer
_value
)
:
value
(
_value
)
{}
AllocatedPath
(
string
&&
_value
)
:
value
(
std
::
move
(
_value
))
{}
AllocatedPath
(
string
&&
_value
)
:
value
(
std
::
move
(
_value
))
{}
...
...
src/fs/Charset.cxx
View file @
4f80a129
...
@@ -157,13 +157,13 @@ PathToUTF8(const char *path_fs)
...
@@ -157,13 +157,13 @@ PathToUTF8(const char *path_fs)
#ifdef HAVE_FS_CHARSET
#ifdef HAVE_FS_CHARSET
char
*
std
::
string
PathFromUTF8
(
const
char
*
path_utf8
)
PathFromUTF8
(
const
char
*
path_utf8
)
{
{
assert
(
path_utf8
!=
nullptr
);
assert
(
path_utf8
!=
nullptr
);
if
(
fs_charset
.
empty
())
if
(
fs_charset
.
empty
())
return
g_strdup
(
path_utf8
)
;
return
path_utf8
;
return
g_convert
(
path_utf8
,
-
1
,
return
g_convert
(
path_utf8
,
-
1
,
fs_charset
.
c_str
(),
"utf-8"
,
fs_charset
.
c_str
(),
"utf-8"
,
...
...
src/fs/Charset.hxx
View file @
4f80a129
...
@@ -52,8 +52,12 @@ gcc_pure gcc_nonnull_all
...
@@ -52,8 +52,12 @@ gcc_pure gcc_nonnull_all
std
::
string
std
::
string
PathToUTF8
(
const
char
*
path_fs
);
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
);
PathFromUTF8
(
const
char
*
path_utf8
);
#endif
#endif
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment