diff options
author | Max Kellermann <max@duempel.org> | 2008-09-16 19:11:39 +0200 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2008-09-16 19:11:39 +0200 |
commit | a6858acfdead6285a010a31b1fc7c8a730e91788 (patch) | |
tree | 3b698b3b2cdfedf680f5ee51f3802f82030ae23a /src/playlist.c | |
parent | eee102e5ddd2c400d707bffe21d9c6ec74507371 (diff) | |
download | mpd-a6858acfdead6285a010a31b1fc7c8a730e91788.tar.gz mpd-a6858acfdead6285a010a31b1fc7c8a730e91788.tar.xz mpd-a6858acfdead6285a010a31b1fc7c8a730e91788.zip |
mpdclient: added mpdclient_playlist_init(), mpdclient_playlist_clear()
Moved code from mpdclient_new() and mpdclient_playlist_free(). In
mpdclient_disconnect(), call mpdclient_playlist_clear() instead of
mpdclient_playlist_free() (which is now called in mpdclient_free()).
Diffstat (limited to '')
-rw-r--r-- | src/playlist.c | 25 |
1 files changed, 22 insertions, 3 deletions
diff --git a/src/playlist.c b/src/playlist.c index e2530435e..b600343d7 100644 --- a/src/playlist.c +++ b/src/playlist.c @@ -29,8 +29,17 @@ #define MPD_ERROR(c) (c==NULL || c->connection==NULL || c->connection->error) -gint -mpdclient_playlist_free(mpdclient_playlist_t *playlist) +void +playlist_init(struct mpdclient_playlist *playlist) +{ + playlist->id = 0; + playlist->updated = FALSE; + playlist->list = g_array_sized_new(FALSE, FALSE, + sizeof(struct mpd_song *), 1024); +} + +void +playlist_clear(struct mpdclient_playlist *playlist) { guint i; @@ -39,7 +48,17 @@ mpdclient_playlist_free(mpdclient_playlist_t *playlist) mpd_freeSong(song); } - g_array_free(playlist->list, TRUE); + g_array_set_size(playlist->list, 0); +} + +gint +mpdclient_playlist_free(mpdclient_playlist_t *playlist) +{ + if (playlist->list != NULL) { + playlist_clear(playlist); + g_array_free(playlist->list, TRUE); + } + memset(playlist, 0, sizeof(mpdclient_playlist_t)); return 0; } |