From: Justin Ruggles Date: Mon, 10 Oct 2011 15:21:07 +0000 (-0400) Subject: alacdec: simplify buffer allocation by using FF_ALLOC_OR_GOTO() X-Git-Tag: v0.8b1~903 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=68f7e9cd8e29d0331f783844bb92d64d208aa861;p=platform%2Fupstream%2Flibav.git alacdec: simplify buffer allocation by using FF_ALLOC_OR_GOTO() --- diff --git a/libavcodec/alac.c b/libavcodec/alac.c index 85a441a..4b44219 100644 --- a/libavcodec/alac.c +++ b/libavcodec/alac.c @@ -548,22 +548,21 @@ static int allocate_buffers(ALACContext *alac) { int ch; for (ch = 0; ch < alac->numchannels; ch++) { - alac->predicterror_buffer[ch] = - av_malloc(alac->setinfo_max_samples_per_frame * 4); + int buf_size = alac->setinfo_max_samples_per_frame * sizeof(int32_t); - alac->outputsamples_buffer[ch] = - av_malloc(alac->setinfo_max_samples_per_frame * 4); + FF_ALLOC_OR_GOTO(alac->avctx, alac->predicterror_buffer[ch], + buf_size, buf_alloc_fail); - alac->extra_bits_buffer[ch] = av_malloc(alac->setinfo_max_samples_per_frame * 4); + FF_ALLOC_OR_GOTO(alac->avctx, alac->outputsamples_buffer[ch], + buf_size, buf_alloc_fail); - if (!alac->predicterror_buffer[ch] || - !alac->outputsamples_buffer[ch] || - !alac->extra_bits_buffer[ch]) { - alac_decode_close(alac->avctx); - return AVERROR(ENOMEM); - } + FF_ALLOC_OR_GOTO(alac->avctx, alac->extra_bits_buffer[ch], + buf_size, buf_alloc_fail); } return 0; +buf_alloc_fail: + alac_decode_close(alac->avctx); + return AVERROR(ENOMEM); } static int alac_set_info(ALACContext *alac)