diff mbox series

[FFmpeg-devel,3/3] avcodec/alac: remove FF_ALLOC_OR_GOTO and gotos label

Message ID 1590845462-9163-3-git-send-email-lance.lmwang@gmail.com
State Accepted
Headers show
Series [FFmpeg-devel,1/3] avutil/dict: av_realloc -> av_realloc_array() | expand

Checks

Context Check Description
andriy/default pending
andriy/make success Make finished
andriy/make_fate success Make fate finished

Commit Message

Lance Wang May 30, 2020, 1:31 p.m. UTC
From: Limin Wang <lance.lmwang@gmail.com>

Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
---
 libavcodec/alac.c | 15 +++++++--------
 1 file changed, 7 insertions(+), 8 deletions(-)
diff mbox series

Patch

diff --git a/libavcodec/alac.c b/libavcodec/alac.c
index 3b41373..bf05406 100644
--- a/libavcodec/alac.c
+++ b/libavcodec/alac.c
@@ -489,6 +489,7 @@  static int allocate_buffers(ALACContext *alac)
 {
     int ch;
     unsigned buf_size = alac->max_samples_per_frame * sizeof(int32_t);
+    unsigned extra_buf_size = buf_size + AV_INPUT_BUFFER_PADDING_SIZE;
 
     for (ch = 0; ch < 2; ch++) {
         alac->predict_error_buffer[ch]  = NULL;
@@ -497,21 +498,19 @@  static int allocate_buffers(ALACContext *alac)
     }
 
     for (ch = 0; ch < FFMIN(alac->channels, 2); ch++) {
-        FF_ALLOC_OR_GOTO(alac->avctx, alac->predict_error_buffer[ch],
-                         buf_size, buf_alloc_fail);
+        if (!(alac->predict_error_buffer[ch] = av_malloc(buf_size)))
+            return AVERROR(ENOMEM);
 
         alac->direct_output = alac->sample_size > 16;
         if (!alac->direct_output) {
-            FF_ALLOC_OR_GOTO(alac->avctx, alac->output_samples_buffer[ch],
-                             buf_size + AV_INPUT_BUFFER_PADDING_SIZE, buf_alloc_fail);
+            if (!(alac->output_samples_buffer[ch] = av_malloc(extra_buf_size)))
+                return AVERROR(ENOMEM);
         }
 
-        FF_ALLOC_OR_GOTO(alac->avctx, alac->extra_bits_buffer[ch],
-                         buf_size + AV_INPUT_BUFFER_PADDING_SIZE, buf_alloc_fail);
+        if (!(alac->extra_bits_buffer[ch] = av_malloc(extra_buf_size)))
+            return AVERROR(ENOMEM);
     }
     return 0;
-buf_alloc_fail:
-    return AVERROR(ENOMEM);
 }
 
 static int alac_set_info(ALACContext *alac)