summaryrefslogtreecommitdiff
path: root/src/SongLoader.cxx
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2016-02-28 11:08:00 +0100
committerMax Kellermann <max@duempel.org>2016-02-28 11:08:00 +0100
commitfe4b1f96f1b061d58f81f47652d9c3c9f4355f67 (patch)
treebc28a5340ff3eedf6625b442a3e4dd7ca556ad1d /src/SongLoader.cxx
parent9de984f7f8ea98fcac544ad3dc046d0a57dccfba (diff)
SongLoader: use temporary stack variable, no heap allocation
Improved exception-safety.
Diffstat (limited to 'src/SongLoader.cxx')
-rw-r--r--src/SongLoader.cxx7
1 files changed, 3 insertions, 4 deletions
diff --git a/src/SongLoader.cxx b/src/SongLoader.cxx
index 637c80284..e68edbef4 100644
--- a/src/SongLoader.cxx
+++ b/src/SongLoader.cxx
@@ -65,15 +65,14 @@ SongLoader::LoadFile(const char *path_utf8, Path path_fs, Error &error) const
}
#endif
- DetachedSong *song = new DetachedSong(path_utf8);
- if (!song->LoadFile(path_fs)) {
+ DetachedSong song(path_utf8);
+ if (!song.LoadFile(path_fs)) {
error.Set(playlist_domain, int(PlaylistResult::NO_SUCH_SONG),
"No such file");
- delete song;
return nullptr;
}
- return song;
+ return new DetachedSong(std::move(song));
}
DetachedSong *