MusicPipe: allocate with new/delete

This commit is contained in:
Max Kellermann 2013-01-04 21:22:07 +01:00
parent c04e1ad401
commit 6886063703
1 changed files with 18 additions and 17 deletions

View File

@ -42,33 +42,34 @@ struct music_pipe {
#ifndef NDEBUG #ifndef NDEBUG
struct audio_format audio_format; struct audio_format audio_format;
#endif #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 * struct music_pipe *
music_pipe_new(void) music_pipe_new(void)
{ {
struct music_pipe *mp = g_new(struct music_pipe, 1); return new music_pipe();
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;
} }
void void
music_pipe_free(struct music_pipe *mp) music_pipe_free(struct music_pipe *mp)
{ {
assert(mp->head == NULL); delete mp;
assert(mp->tail_r == &mp->head);
g_mutex_free(mp->mutex);
g_free(mp);
} }
#ifndef NDEBUG #ifndef NDEBUG