aboutsummaryrefslogtreecommitdiffstats
path: root/src/Song.cxx
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2013-10-17 01:01:15 +0200
committerMax Kellermann <max@duempel.org>2013-10-17 01:01:15 +0200
commitbe8ceae6e6c2836233dd8acedd829b18943f820a (patch)
treef625c58523ccee5c27c082c49e15c2d142d836fb /src/Song.cxx
parent67ae033de7e769067035f76c992e21d3616bf3fe (diff)
downloadmpd-be8ceae6e6c2836233dd8acedd829b18943f820a.tar.gz
mpd-be8ceae6e6c2836233dd8acedd829b18943f820a.tar.xz
mpd-be8ceae6e6c2836233dd8acedd829b18943f820a.zip
Song: GetURI() returns std::string
Diffstat (limited to '')
-rw-r--r--src/Song.cxx31
1 files changed, 17 insertions, 14 deletions
diff --git a/src/Song.cxx b/src/Song.cxx
index 5ee4c5545..c63dc8753 100644
--- a/src/Song.cxx
+++ b/src/Song.cxx
@@ -89,9 +89,8 @@ Song::DupDetached() const
{
Song *song;
if (IsInDatabase()) {
- char *new_uri = GetURI();
- song = NewDetached(new_uri);
- g_free(new_uri);
+ const auto new_uri = GetURI();
+ song = NewDetached(new_uri.c_str());
} else
song = song_alloc(uri, nullptr);
@@ -138,28 +137,32 @@ song_equals(const Song *a, const Song *b)
(a->parent == &detached_root || b->parent == &detached_root)) {
/* must compare the full URI if one of the objects is
"detached" */
- char *au = a->GetURI();
- char *bu = b->GetURI();
- const bool result = strcmp(au, bu) == 0;
- g_free(bu);
- g_free(au);
- return result;
+ const auto au = a->GetURI();
+ const auto bu = b->GetURI();
+ return au == bu;
}
return directory_is_same(a->parent, b->parent) &&
strcmp(a->uri, b->uri) == 0;
}
-char *
+std::string
Song::GetURI() const
{
assert(*uri);
if (!IsInDatabase() || parent->IsRoot())
- return g_strdup(uri);
- else
- return g_strconcat(parent->GetPath(),
- "/", uri, nullptr);
+ return std::string(uri);
+ else {
+ const char *path = parent->GetPath();
+
+ std::string result;
+ result.reserve(strlen(path) + 1 + strlen(uri));
+ result.assign(path);
+ result.push_back('/');
+ result.append(uri);
+ return result;
+ }
}
double