Simplify alloc_table().
authorAndre Noll <maan@systemlinux.org>
Sun, 18 Oct 2009 11:39:28 +0000 (13:39 +0200)
committerAndre Noll <maan@systemlinux.org>
Wed, 18 Nov 2009 18:34:19 +0000 (19:34 +0100)
bitstream.c

index e081d0cf61ad7b711065d3d7c4844a3a9691f148..2522b6d4e0a2be6e738fe5f1632c9f788e98a978 100644 (file)
        } \
 }
 
        } \
 }
 
-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);
        }
        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,
 }
 
 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;
        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++) {
        table = &vlc->table[table_index];
 
        for (i = 0; i < table_size; i++) {