From 28b47725ffed5aa1ecb7812abda65d84275cb50d Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Tue, 28 Oct 2008 20:43:15 +0100 Subject: mp3: use GLib allocation functions This removes the need for util.h. --- src/decoder/mp3_plugin.c | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) (limited to 'src') diff --git a/src/decoder/mp3_plugin.c b/src/decoder/mp3_plugin.c index 88015636a..ee1d9f2bd 100644 --- a/src/decoder/mp3_plugin.c +++ b/src/decoder/mp3_plugin.c @@ -18,9 +18,11 @@ #include "../decoder_api.h" #include "../log.h" -#include "../utils.h" #include "../conf.h" +#include +#include +#include #include #include @@ -263,10 +265,7 @@ static void mp3_parse_id3(struct mp3_data *data, size_t tagsize, id3_data = data->stream.this_frame; mad_stream_skip(&(data->stream), tagsize); } else { - allocated = xmalloc(tagsize); - if (!allocated) - goto fail; - + allocated = g_malloc(tagsize); memcpy(allocated, data->stream.this_frame, count); mad_stream_skip(&(data->stream), count); @@ -313,8 +312,7 @@ static void mp3_parse_id3(struct mp3_data *data, size_t tagsize, id3_tag_delete(id3_tag); fail: - if (allocated) - free(allocated); + g_free(allocated); } #endif @@ -732,8 +730,8 @@ mp3_decode_first_frame(struct mp3_data *data, struct tag **tag, return false; } - data->frame_offsets = xmalloc(sizeof(long) * data->max_frames); - data->times = xmalloc(sizeof(mad_timer_t) * data->max_frames); + data->frame_offsets = g_malloc(sizeof(long) * data->max_frames); + data->times = g_malloc(sizeof(mad_timer_t) * data->max_frames); return true; } @@ -744,8 +742,8 @@ static void mp3_data_finish(struct mp3_data *data) mad_frame_finish(&data->frame); mad_stream_finish(&data->stream); - if (data->frame_offsets) free(data->frame_offsets); - if (data->times) free(data->times); + g_free(data->frame_offsets); + g_free(data->times); } /* this is primarily used for getting total time for tags */ -- cgit v1.2.3