From bbdf2dcf1e569505a2d01e18b8dda6ddd4b9e38f Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Tue, 21 May 2019 22:46:34 +0200 Subject: db/simple/Song: wrap in std::unique_ptr<> --- src/SongUpdate.cxx | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) (limited to 'src/SongUpdate.cxx') 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; } -- cgit v1.2.3