summaryrefslogtreecommitdiff
path: root/src/SongUpdate.cxx
diff options
context:
space:
mode:
authorMax Kellermann <max@musicpd.org>2019-05-21 22:46:34 +0200
committerMax Kellermann <max@musicpd.org>2019-05-21 22:46:34 +0200
commitbbdf2dcf1e569505a2d01e18b8dda6ddd4b9e38f (patch)
treec09e64eb2cb5edc448bf2c0322139b32251b2e0f /src/SongUpdate.cxx
parent02bb47dd0857cdd738c9e0665a1f22c937e6ddf0 (diff)
db/simple/Song: wrap in std::unique_ptr<>
Diffstat (limited to 'src/SongUpdate.cxx')
-rw-r--r--src/SongUpdate.cxx16
1 files changed, 6 insertions, 10 deletions
diff --git a/src/SongUpdate.cxx b/src/SongUpdate.cxx
index 0d22ff1d8..9887da507 100644
--- a/src/SongUpdate.cxx
+++ b/src/SongUpdate.cxx
@@ -41,18 +41,16 @@
#ifdef ENABLE_DATABASE
-Song *
+SongPtr
Song::LoadFile(Storage &storage, const char *path_utf8,
Directory &parent) noexcept
{
assert(!uri_has_scheme(path_utf8));
assert(strchr(path_utf8, '\n') == nullptr);
- Song *song = NewFile(path_utf8, parent);
- if (!song->UpdateFile(storage)) {
- song->Free();
+ auto song = NewFile(path_utf8, parent);
+ if (!song->UpdateFile(storage))
return nullptr;
- }
return song;
}
@@ -102,19 +100,17 @@ Song::UpdateFile(Storage &storage) noexcept
#ifdef ENABLE_ARCHIVE
-Song *
+SongPtr
Song::LoadFromArchive(ArchiveFile &archive, const char *name_utf8,
Directory &parent) noexcept
{
assert(!uri_has_scheme(name_utf8));
assert(strchr(name_utf8, '\n') == nullptr);
- Song *song = NewFile(name_utf8, parent);
+ auto song = NewFile(name_utf8, parent);
- if (!song->UpdateFileInArchive(archive)) {
- song->Free();
+ if (!song->UpdateFileInArchive(archive))
return nullptr;
- }
return song;
}