From: Yunqing Wang Date: Thu, 11 Oct 2012 15:46:23 +0000 (-0700) Subject: Clean up error return code in alloccommon.c X-Git-Tag: v1.2.0~52 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=52bddd44c0f8e4788e2073186816b9b2c032ad16;p=libvpx Clean up error return code in alloccommon.c Clean up the duplicate code as Pascal suggested. Change-Id: I685fcbb488502e969f6cb73a46db3ea79b90910d --- diff --git a/vp8/common/alloccommon.c b/vp8/common/alloccommon.c index 86a0971ac..a03f882dc 100644 --- a/vp8/common/alloccommon.c +++ b/vp8/common/alloccommon.c @@ -63,10 +63,7 @@ int vp8_alloc_frame_buffers(VP8_COMMON *oci, int width, int height) oci->fb_idx_ref_cnt[i] = 0; oci->yv12_fb[i].flags = 0; if (vp8_yv12_alloc_frame_buffer(&oci->yv12_fb[i], width, height, VP8BORDERINPIXELS) < 0) - { - vp8_de_alloc_frame_buffers(oci); - return 1; - } + goto allocation_fail; } oci->new_fb_idx = 0; @@ -80,10 +77,7 @@ int vp8_alloc_frame_buffers(VP8_COMMON *oci, int width, int height) oci->fb_idx_ref_cnt[3] = 1; if (vp8_yv12_alloc_frame_buffer(&oci->temp_scale_frame, width, 16, VP8BORDERINPIXELS) < 0) - { - vp8_de_alloc_frame_buffers(oci); - return 1; - } + goto allocation_fail; oci->mb_rows = height >> 4; oci->mb_cols = width >> 4; @@ -92,10 +86,7 @@ int vp8_alloc_frame_buffers(VP8_COMMON *oci, int width, int height) oci->mip = vpx_calloc((oci->mb_cols + 1) * (oci->mb_rows + 1), sizeof(MODE_INFO)); if (!oci->mip) - { - vp8_de_alloc_frame_buffers(oci); - return 1; - } + goto allocation_fail; oci->mi = oci->mip + oci->mode_info_stride + 1; @@ -105,17 +96,11 @@ int vp8_alloc_frame_buffers(VP8_COMMON *oci, int width, int height) oci->above_context = vpx_calloc(sizeof(ENTROPY_CONTEXT_PLANES) * oci->mb_cols, 1); if (!oci->above_context) - { - vp8_de_alloc_frame_buffers(oci); - return 1; - } + goto allocation_fail; #if CONFIG_POSTPROC if (vp8_yv12_alloc_frame_buffer(&oci->post_proc_buffer, width, height, VP8BORDERINPIXELS) < 0) - { - vp8_de_alloc_frame_buffers(oci); - return 1; - } + goto allocation_fail; oci->post_proc_buffer_int_used = 0; vpx_memset(&oci->postproc_state, 0, sizeof(oci->postproc_state)); @@ -125,14 +110,16 @@ int vp8_alloc_frame_buffers(VP8_COMMON *oci, int width, int height) /* Allocate buffer to store post-processing filter coefficients. */ oci->pp_limits_buffer = vpx_memalign(16, 24 * oci->mb_cols); if (!oci->pp_limits_buffer) - { - vp8_de_alloc_frame_buffers(oci); - return 1; - } + goto allocation_fail; #endif return 0; + +allocation_fail: + vp8_de_alloc_frame_buffers(oci); + return 1; } + void vp8_setup_version(VP8_COMMON *cm) { switch (cm->version)