From ee3c423f1c081600367fd0da2b09e5a05e2088b7 Mon Sep 17 00:00:00 2001 From: Andre Noll Date: Sun, 18 Oct 2009 13:39:28 +0200 Subject: [PATCH] Simplify alloc_table(). --- bitstream.c | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/bitstream.c b/bitstream.c index e081d0cf..2522b6d4 100644 --- a/bitstream.c +++ b/bitstream.c @@ -43,18 +43,14 @@ } \ } -static int alloc_table(struct vlc *vlc, int size) +static void alloc_table(struct vlc *vlc, int size) { - int idx; - - idx = vlc->table_size; vlc->table_size += size; if (vlc->table_size > vlc->table_allocated) { vlc->table_allocated += (1 << vlc->bits); vlc->table = para_realloc(vlc->table, sizeof(VLC_TYPE) * 2 * vlc->table_allocated); } - return idx; } static int build_table(struct vlc *vlc, int table_nb_bits, int nb_codes, @@ -67,10 +63,8 @@ static int build_table(struct vlc *vlc, int table_nb_bits, int nb_codes, VLC_TYPE(*table)[2]; table_size = 1 << table_nb_bits; - ret = alloc_table(vlc, table_size); - if (ret < 0) - return ret; - table_index = ret; + table_index = vlc->table_size; + alloc_table(vlc, table_size); table = &vlc->table[table_index]; for (i = 0; i < table_size; i++) { -- 2.39.5