SongLoader: use temporary stack variable, no heap allocation
Improved exception-safety.
This commit is contained in:
parent
9de984f7f8
commit
fe4b1f96f1
@ -65,15 +65,14 @@ SongLoader::LoadFile(const char *path_utf8, Path path_fs, Error &error) const
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
DetachedSong *song = new DetachedSong(path_utf8);
|
DetachedSong song(path_utf8);
|
||||||
if (!song->LoadFile(path_fs)) {
|
if (!song.LoadFile(path_fs)) {
|
||||||
error.Set(playlist_domain, int(PlaylistResult::NO_SUCH_SONG),
|
error.Set(playlist_domain, int(PlaylistResult::NO_SUCH_SONG),
|
||||||
"No such file");
|
"No such file");
|
||||||
delete song;
|
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
return song;
|
return new DetachedSong(std::move(song));
|
||||||
}
|
}
|
||||||
|
|
||||||
DetachedSong *
|
DetachedSong *
|
||||||
|
Loading…
Reference in New Issue
Block a user