diff options
author | Max Kellermann <max@duempel.org> | 2013-01-04 21:22:07 +0100 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2013-01-04 21:22:07 +0100 |
commit | 6886063703704796f03d7bfe35747fc2cb01ded2 (patch) | |
tree | 130dccf15acf653044173d84b064cc94766b2fa5 /src/MusicPipe.cxx | |
parent | c04e1ad401e4a2d2c18c48344a4cd2fa75fc12a5 (diff) | |
download | mpd-6886063703704796f03d7bfe35747fc2cb01ded2.tar.gz mpd-6886063703704796f03d7bfe35747fc2cb01ded2.tar.xz mpd-6886063703704796f03d7bfe35747fc2cb01ded2.zip |
MusicPipe: allocate with new/delete
Diffstat (limited to '')
-rw-r--r-- | src/MusicPipe.cxx | 35 |
1 files changed, 18 insertions, 17 deletions
diff --git a/src/MusicPipe.cxx b/src/MusicPipe.cxx index d9fc07eca..38c3af776 100644 --- a/src/MusicPipe.cxx +++ b/src/MusicPipe.cxx @@ -42,33 +42,34 @@ struct music_pipe { #ifndef NDEBUG struct audio_format audio_format; #endif + + music_pipe() + :head(nullptr), tail_r(&head), + size(0), + mutex(g_mutex_new()) { +#ifndef NDEBUG + audio_format_clear(&audio_format); +#endif + } + + ~music_pipe() { + assert(head == nullptr); + assert(tail_r == &head); + + g_mutex_free(mutex); + } }; struct music_pipe * music_pipe_new(void) { - struct music_pipe *mp = g_new(struct music_pipe, 1); - - mp->head = NULL; - mp->tail_r = &mp->head; - mp->size = 0; - mp->mutex = g_mutex_new(); - -#ifndef NDEBUG - audio_format_clear(&mp->audio_format); -#endif - - return mp; + return new music_pipe(); } void music_pipe_free(struct music_pipe *mp) { - assert(mp->head == NULL); - assert(mp->tail_r == &mp->head); - - g_mutex_free(mp->mutex); - g_free(mp); + delete mp; } #ifndef NDEBUG |