From 3cc7be0fa6ad68fae6f3d1938e2f7f5a2e951454 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Tue, 9 Apr 2013 00:34:48 +0200 Subject: playlist/cue: add constructor/destructor --- src/playlist/CuePlaylistPlugin.cxx | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) (limited to 'src/playlist/CuePlaylistPlugin.cxx') diff --git a/src/playlist/CuePlaylistPlugin.cxx b/src/playlist/CuePlaylistPlugin.cxx index 07eb5e243..71ae2261a 100644 --- a/src/playlist/CuePlaylistPlugin.cxx +++ b/src/playlist/CuePlaylistPlugin.cxx @@ -42,18 +42,23 @@ struct CuePlaylist { struct input_stream *is; struct text_input_stream *tis; struct cue_parser *parser; + + CuePlaylist(struct input_stream *_is) + :is(_is), tis(text_input_stream_new(is)), + parser(cue_parser_new()) { + playlist_provider_init(&base, &cue_playlist_plugin); + } + + ~CuePlaylist() { + cue_parser_free(parser); + text_input_stream_free(tis); + } }; static struct playlist_provider * cue_playlist_open_stream(struct input_stream *is) { - CuePlaylist *playlist = g_new(CuePlaylist, 1); - playlist_provider_init(&playlist->base, &cue_playlist_plugin); - - playlist->is = is; - playlist->tis = text_input_stream_new(is); - playlist->parser = cue_parser_new(); - + CuePlaylist *playlist = new CuePlaylist(is); return &playlist->base; } @@ -61,10 +66,7 @@ static void cue_playlist_close(struct playlist_provider *_playlist) { CuePlaylist *playlist = (CuePlaylist *)_playlist; - - cue_parser_free(playlist->parser); - text_input_stream_free(playlist->tis); - g_free(playlist); + delete playlist; } static struct song * -- cgit v1.2.3