aboutsummaryrefslogtreecommitdiff
path: root/src/playlist/MemoryPlaylistProvider.cxx
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2013-01-29 18:51:40 +0100
committerMax Kellermann <max@duempel.org>2013-01-29 20:32:54 +0100
commit8cad20585dbbf5987d6649bea9c6b6ba688b7bff (patch)
treeb93e9dbd1e3f6e8f895ea53b2d5bfec09e6fab46 /src/playlist/MemoryPlaylistProvider.cxx
parenta8b75dc4df3bf3ba9a1554249cf6d07527184864 (diff)
playlist/memory: use std::forward_list instead of GSList
Diffstat (limited to 'src/playlist/MemoryPlaylistProvider.cxx')
-rw-r--r--src/playlist/MemoryPlaylistProvider.cxx27
1 files changed, 6 insertions, 21 deletions
diff --git a/src/playlist/MemoryPlaylistProvider.cxx b/src/playlist/MemoryPlaylistProvider.cxx
index b643ec50..4fe3d6ce 100644
--- a/src/playlist/MemoryPlaylistProvider.cxx
+++ b/src/playlist/MemoryPlaylistProvider.cxx
@@ -52,33 +52,18 @@ static constexpr struct playlist_plugin memory_playlist_plugin = {
nullptr,
};
-MemoryPlaylistProvider::MemoryPlaylistProvider(GSList *_songs)
- :songs(_songs) {
+MemoryPlaylistProvider::MemoryPlaylistProvider(std::forward_list<SongPointer> &&_songs)
+ :songs(std::move(_songs)) {
playlist_provider_init(this, &memory_playlist_plugin);
}
-static void
-song_free_callback(gpointer data, G_GNUC_UNUSED gpointer user_data)
-{
- struct song *song = (struct song *)data;
-
- song_free(song);
-}
-
-MemoryPlaylistProvider::~MemoryPlaylistProvider()
-{
- g_slist_foreach(songs, song_free_callback, NULL);
- g_slist_free(songs);
-}
-
inline song *
MemoryPlaylistProvider::Read()
{
- if (songs == nullptr)
- return nullptr;
+ if (songs.empty())
+ return NULL;
- song *result = (song *)songs->data;
- songs = g_slist_remove(songs, result);
+ auto result = songs.front().Steal();
+ songs.pop_front();
return result;
}
-