diff options
author | Max Kellermann <max@duempel.org> | 2016-02-07 11:58:17 +0100 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2016-02-07 11:58:17 +0100 |
commit | e2a0fd7a284e447e21a78e06c4f9481f4ec9b8a3 (patch) | |
tree | 4681ddf95345c088378c5a50b672a8e04a15e0e4 /src/playlist | |
parent | 5869a4ba2d7920076dd7d3cc147660c580fb2c03 (diff) |
playlist/cue/CueParser: Get() returns std::unique_ptr
Diffstat (limited to 'src/playlist')
-rw-r--r-- | src/playlist/cue/CueParser.cxx | 6 | ||||
-rw-r--r-- | src/playlist/cue/CueParser.hxx | 2 | ||||
-rw-r--r-- | src/playlist/plugins/CuePlaylistPlugin.cxx | 8 | ||||
-rw-r--r-- | src/playlist/plugins/EmbeddedCuePlaylistPlugin.cxx | 8 |
4 files changed, 13 insertions, 11 deletions
diff --git a/src/playlist/cue/CueParser.cxx b/src/playlist/cue/CueParser.cxx index c74973e03..25a5529eb 100644 --- a/src/playlist/cue/CueParser.cxx +++ b/src/playlist/cue/CueParser.cxx @@ -281,7 +281,7 @@ CueParser::Finish() end = true; } -DetachedSong * +std::unique_ptr<DetachedSong> CueParser::Get() { if (finished == nullptr && end) { @@ -293,5 +293,7 @@ CueParser::Get() previous.reset(); } - return finished.release(); + auto result = std::move(finished); + finished.reset(); + return result; } diff --git a/src/playlist/cue/CueParser.hxx b/src/playlist/cue/CueParser.hxx index ea9782bef..af78c3c70 100644 --- a/src/playlist/cue/CueParser.hxx +++ b/src/playlist/cue/CueParser.hxx @@ -118,7 +118,7 @@ public: * @return a song object that must be freed by the caller, or NULL if * no song was finished at this time */ - DetachedSong *Get(); + std::unique_ptr<DetachedSong> Get(); private: gcc_pure diff --git a/src/playlist/plugins/CuePlaylistPlugin.cxx b/src/playlist/plugins/CuePlaylistPlugin.cxx index df6946abc..4b635f71f 100644 --- a/src/playlist/plugins/CuePlaylistPlugin.cxx +++ b/src/playlist/plugins/CuePlaylistPlugin.cxx @@ -48,20 +48,20 @@ cue_playlist_open_stream(InputStream &is) DetachedSong * CuePlaylist::NextSong() { - DetachedSong *song = parser.Get(); + auto song = parser.Get(); if (song != nullptr) - return song; + return song.release(); const char *line; while ((line = tis.ReadLine()) != nullptr) { parser.Feed(line); song = parser.Get(); if (song != nullptr) - return song; + return song.release(); } parser.Finish(); - return parser.Get(); + return parser.Get().release(); } static const char *const cue_playlist_suffixes[] = { diff --git a/src/playlist/plugins/EmbeddedCuePlaylistPlugin.cxx b/src/playlist/plugins/EmbeddedCuePlaylistPlugin.cxx index e12dc2df0..72fb75253 100644 --- a/src/playlist/plugins/EmbeddedCuePlaylistPlugin.cxx +++ b/src/playlist/plugins/EmbeddedCuePlaylistPlugin.cxx @@ -127,10 +127,10 @@ embcue_playlist_open_uri(const char *uri, DetachedSong * EmbeddedCuePlaylist::NextSong() { - DetachedSong *song = parser->Get(); + auto song = parser->Get(); if (song != nullptr) { song->SetURI(filename); - return song; + return song.release(); } while (*next != 0) { @@ -149,7 +149,7 @@ EmbeddedCuePlaylist::NextSong() song = parser->Get(); if (song != nullptr) { song->SetURI(filename); - return song; + return song.release(); } } @@ -157,7 +157,7 @@ EmbeddedCuePlaylist::NextSong() song = parser->Get(); if (song != nullptr) song->SetURI(filename); - return song; + return song.release(); } static const char *const embcue_playlist_suffixes[] = { |