diff options
author | Justin Ruggles <justin.ruggles@gmail.com> | 2011-10-10 11:21:07 -0400 |
---|---|---|
committer | Justin Ruggles <justin.ruggles@gmail.com> | 2011-10-26 11:50:17 -0400 |
commit | 68f7e9cd8e29d0331f783844bb92d64d208aa861 (patch) | |
tree | 4bfabd967a01c8725c1b9e8cce320509ff042158 | |
parent | b316af7a7c6b20ded1fd996933e47d4feb89aac9 (diff) | |
download | ffmpeg-68f7e9cd8e29d0331f783844bb92d64d208aa861.tar.gz |
alacdec: simplify buffer allocation by using FF_ALLOC_OR_GOTO()
-rw-r--r-- | libavcodec/alac.c | 21 |
1 files changed, 10 insertions, 11 deletions
diff --git a/libavcodec/alac.c b/libavcodec/alac.c index 85a441abe8..4b442196e9 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) |