aboutsummaryrefslogtreecommitdiffstats
path: root/src/playlist/DespotifyPlaylistPlugin.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/DespotifyPlaylistPlugin.cxx
parenta8b75dc4df3bf3ba9a1554249cf6d07527184864 (diff)
downloadmpd-8cad20585dbbf5987d6649bea9c6b6ba688b7bff.tar.gz
mpd-8cad20585dbbf5987d6649bea9c6b6ba688b7bff.tar.xz
mpd-8cad20585dbbf5987d6649bea9c6b6ba688b7bff.zip
playlist/memory: use std::forward_list instead of GSList
Diffstat (limited to 'src/playlist/DespotifyPlaylistPlugin.cxx')
-rw-r--r--src/playlist/DespotifyPlaylistPlugin.cxx21
1 files changed, 8 insertions, 13 deletions
diff --git a/src/playlist/DespotifyPlaylistPlugin.cxx b/src/playlist/DespotifyPlaylistPlugin.cxx
index 09c1aa899..17bcf0f6c 100644
--- a/src/playlist/DespotifyPlaylistPlugin.cxx
+++ b/src/playlist/DespotifyPlaylistPlugin.cxx
@@ -35,7 +35,8 @@ extern "C" {
struct despotify_playlist {
struct despotify_session *session;
- GSList *list;
+
+ std::forward_list<SongPointer> songs;
};
static void
@@ -59,7 +60,7 @@ add_song(struct despotify_playlist *ctx, struct ds_track *track)
song = song_remote_new(uri);
song->tag = mpd_despotify_tag_from_track(track);
- ctx->list = g_slist_prepend(ctx->list, song);
+ ctx->songs.emplace_front(song);
}
static bool
@@ -115,17 +116,16 @@ despotify_playlist_open_uri(const char *url,
session = mpd_despotify_get_session();
if (!session)
- goto clean_none;
+ return nullptr;
/* Get link without spt:// */
link = despotify_link_from_uri(url + strlen(despotify_playlist_plugin.schemes[0]) + 3);
if (!link) {
g_debug("Can't find %s\n", url);
- goto clean_none;
+ return nullptr;
}
struct despotify_playlist ctx;
- ctx.list = nullptr;
ctx.session = session;
switch (link->type)
@@ -142,15 +142,10 @@ despotify_playlist_open_uri(const char *url,
}
despotify_free_link(link);
if (!parse_result)
- goto clean_playlist;
-
- return new MemoryPlaylistProvider(g_slist_reverse(ctx.list));
-
-clean_playlist:
- g_slist_free(ctx.list);
-clean_none:
+ return nullptr;
- return nullptr;
+ ctx.songs.reverse();
+ return new MemoryPlaylistProvider(std::move(ctx.songs));
}
static const char *const despotify_schemes[] = {