db/simple: wrap LightSong in Manual<>

Prepare to make LightSong non-assignable.
This commit is contained in:
Max Kellermann
2018-07-06 16:46:01 +02:00
parent 86a02871fc
commit ebc006ab52
2 changed files with 12 additions and 9 deletions

View File

@@ -237,30 +237,32 @@ SimpleDatabase::GetSong(const char *uri) const
throw DatabaseError(DatabaseErrorCode::NOT_FOUND,
"No such song");
light_song = song->Export();
light_song.Construct(song->Export());
#ifndef NDEBUG
++borrowed_song_count;
#endif
return &light_song;
return &light_song.Get();
}
void
SimpleDatabase::ReturnSong(gcc_unused const LightSong *song) const
{
assert(song != nullptr);
assert(song == &light_song || song == prefixed_light_song);
delete prefixed_light_song;
prefixed_light_song = nullptr;
assert(song == &light_song.Get() || song == prefixed_light_song);
if (prefixed_light_song != nullptr) {
delete prefixed_light_song;
prefixed_light_song = nullptr;
} else {
#ifndef NDEBUG
if (song == &light_song) {
assert(borrowed_song_count > 0);
--borrowed_song_count;
}
#endif
light_song.Destruct();
}
}
void