]> wimlib.net Git - wimlib/commitdiff
Replaced all "uint" with "unsigned"
authorEric Biggers <ebiggers3@gmail.com>
Thu, 20 Dec 2012 02:51:32 +0000 (20:51 -0600)
committerEric Biggers <ebiggers3@gmail.com>
Thu, 20 Dec 2012 02:51:32 +0000 (20:51 -0600)
src/compress.c
src/decompress.c
src/lz77.c
src/util.h

index 02ff35dd889ffb73344e2a95fc2c59d9204b658a..34e63997956c5a7bab91b600b06d140449a0772e 100644 (file)
@@ -39,9 +39,9 @@ static inline void flush_bits(struct output_bitstream *ostream)
 /* Writes @num_bits bits, given by the @num_bits least significant bits of
  * @bits, to the output @ostream. */
 int bitstream_put_bits(struct output_bitstream *ostream, output_bitbuf_t bits,
-                      uint num_bits)
+                      unsigned num_bits)
 {
-       uint rem_bits;
+       unsigned rem_bits;
 
        wimlib_assert(num_bits <= 16);
        if (num_bits <= ostream->free_bits) {
@@ -88,7 +88,7 @@ int flush_output_bitstream(struct output_bitstream *ostream)
 /* Initializes an output bit buffer to write its output to the memory location
  * pointer to by @data. */
 void init_output_bitstream(struct output_bitstream *ostream, void *data,
-                          uint num_bytes)
+                          unsigned num_bytes)
 {
        wimlib_assert(num_bytes >= 4);
 
@@ -223,7 +223,7 @@ static void huffman_tree_compute_path_lengths(HuffmanNode *node, u16 cur_len)
  *                     lens[i] bits of codewords[i] will contain the codeword
  *                     for symbol i.
  */
-void make_canonical_huffman_code(uint num_syms, uint max_codeword_len,
+void make_canonical_huffman_code(unsigned num_syms, unsigned max_codeword_len,
                                 const u32 freq_tab[], u8 lens[],
                                 u16 codewords[])
 {
@@ -238,8 +238,8 @@ void make_canonical_huffman_code(uint num_syms, uint max_codeword_len,
 
        /* Calculate how many symbols have non-zero frequency.  These are the
         * symbols that actually appeared in the input. */
-       uint num_used_symbols = 0;
-       for (uint i = 0; i < num_syms; i++)
+       unsigned num_used_symbols = 0;
+       for (unsigned i = 0; i < num_syms; i++)
                if (freq_tab[i] != 0)
                        num_used_symbols++;
 
@@ -251,8 +251,8 @@ void make_canonical_huffman_code(uint num_syms, uint max_codeword_len,
        /* Initialize the array of leaf nodes with the symbols and their
         * frequencies. */
        HuffmanLeafNode leaves[num_used_symbols];
-       uint leaf_idx = 0;
-       for (uint i = 0; i < num_syms; i++) {
+       unsigned leaf_idx = 0;
+       for (unsigned i = 0; i < num_syms; i++) {
                if (freq_tab[i] != 0) {
                        leaves[leaf_idx].freq = freq_tab[i];
                        leaves[leaf_idx].sym  = i;
@@ -276,7 +276,7 @@ void make_canonical_huffman_code(uint num_syms, uint max_codeword_len,
                         * encoded data take up more room anyway, since binary
                         * data itself has 2 symbols. */
 
-                       uint sym = leaves[0].sym;
+                       unsigned sym = leaves[0].sym;
 
                        codewords[0] = 0;
                        lens[0]      = 1;
@@ -401,7 +401,7 @@ try_building_tree_again:
                         * codewords approach the length
                         * log_2(num_used_symbols).
                         * */
-                       for (uint i = 0; i < num_used_symbols; i++)
+                       for (unsigned i = 0; i < num_used_symbols; i++)
                                if (leaves[i].freq > 1)
                                        leaves[i].freq >>= 1;
                        goto try_building_tree_again;
@@ -423,8 +423,8 @@ try_building_tree_again:
        qsort(leaves, num_used_symbols, sizeof(leaves[0]), cmp_leaves_by_code_len);
 
        u16 cur_codeword = 0;
-       uint cur_codeword_len = 0;
-       for (uint i = 0; i < num_used_symbols; i++) {
+       unsigned cur_codeword_len = 0;
+       for (unsigned i = 0; i < num_used_symbols; i++) {
 
                /* Each time a codeword becomes one longer, the current codeword
                 * is left shifted by one place.  This is part of the procedure
@@ -432,7 +432,7 @@ try_building_tree_again:
                 * whenever a codeword is used, 1 is added to the current
                 * codeword.  */
 
-               uint len_diff = leaves[i].path_len - cur_codeword_len;
+               unsigned len_diff = leaves[i].path_len - cur_codeword_len;
                cur_codeword <<= len_diff;
                cur_codeword_len += len_diff;
 
index 47ce9943b23cb90bc263f33fad25588d727ba143..069403314a0c886d70e52892897c3151ce322f0a 100644 (file)
@@ -154,9 +154,9 @@ int align_input_bitstream(struct input_bitstream *stream,
  * entries from pointers by the fact that values less than @num_syms must be
  * symbol values.
  */
-int make_huffman_decode_table(u16 decode_table[],  uint num_syms,
-                             uint num_bits, const u8 lens[],
-                             uint max_code_len)
+int make_huffman_decode_table(u16 decode_table[],  unsigned num_syms,
+                             unsigned num_bits, const u8 lens[],
+                             unsigned max_code_len)
 {
        /* Number of entries in the decode table. */
        u32 table_num_entries = 1 << num_bits;
@@ -173,7 +173,7 @@ int make_huffman_decode_table(u16 decode_table[],  uint num_syms,
         * array, and both symbols have the same code length, then we know that
         * the code for A numerically precedes the code for B.
         * */
-       for (uint code_len = 1; code_len <= num_bits; code_len++) {
+       for (unsigned code_len = 1; code_len <= num_bits; code_len++) {
 
                /* Number of entries that a code of length @code_length would
                 * need.  */
@@ -182,7 +182,7 @@ int make_huffman_decode_table(u16 decode_table[],  uint num_syms,
 
                /* For each symbol of length @code_len, fill in its entries in
                 * the decode table. */
-               for (uint sym = 0; sym < num_syms; sym++) {
+               for (unsigned sym = 0; sym < num_syms; sym++) {
 
                        if (lens[sym] != code_len)
                                continue;
@@ -200,7 +200,7 @@ int make_huffman_decode_table(u16 decode_table[],  uint num_syms,
 
                        /* Fill all possible lookups of this symbol with
                         * the symbol itself. */
-                       for (uint i = 0; i < code_num_entries; i++)
+                       for (unsigned i = 0; i < code_num_entries; i++)
                                decode_table[decode_table_pos + i] = sym;
 
                        /* Increment the position in the decode table by
@@ -222,7 +222,7 @@ int make_huffman_decode_table(u16 decode_table[],  uint num_syms,
 
        /* First, zero out the rest of the entries; this is necessary so
         * that the entries appear as "unallocated" in the next part.  */
-       for (uint i = decode_table_pos; i < table_num_entries; i++)
+       for (unsigned i = decode_table_pos; i < table_num_entries; i++)
                decode_table[i] = 0;
 
        /* Assert that 2**num_bits is at least num_syms.  If this wasn't the
@@ -232,30 +232,30 @@ int make_huffman_decode_table(u16 decode_table[],  uint num_syms,
 
 
        /* The current Huffman code.  */
-       uint current_code = decode_table_pos;
+       unsigned current_code = decode_table_pos;
 
        /* The tree nodes are allocated starting at
         * decode_table[table_num_entries].  Remember that the full size of the
         * table, including the extra space for the tree nodes, is actually
         * 2**num_bits + 2 * num_syms slots, while table_num_entries is only
         * 2**num_bits. */
-       uint next_free_tree_slot = table_num_entries;
+       unsigned next_free_tree_slot = table_num_entries;
 
        /* Go through every codeword of length greater than @num_bits.  Note:
         * the LZX format guarantees that the codeword length can be at most 16
         * bits. */
-       for (uint code_len = num_bits + 1; code_len <= max_code_len;
+       for (unsigned code_len = num_bits + 1; code_len <= max_code_len;
                                                        code_len++)
        {
                current_code <<= 1;
-               for (uint sym = 0; sym < num_syms; sym++) {
+               for (unsigned sym = 0; sym < num_syms; sym++) {
                        if (lens[sym] != code_len)
                                continue;
 
 
                        /* i is the index of the current node; find it from the
                         * prefix of the current Huffman code. */
-                       uint i = current_code >> (code_len - num_bits);
+                       unsigned i = current_code >> (code_len - num_bits);
 
                        if (i >= (1 << num_bits)) {
                                ERROR("Invalid canonical Huffman code");
@@ -314,7 +314,7 @@ int make_huffman_decode_table(u16 decode_table[],  uint num_syms,
 
        if (decode_table_pos != table_num_entries) {
 
-               for (uint i = 0; i < num_syms; i++) {
+               for (unsigned i = 0; i < num_syms; i++) {
                        if (lens[i] != 0) {
                                ERROR("Lengths do not form a valid canonical "
                                      "Huffman tree (only filled %u of %u "
@@ -332,12 +332,12 @@ int make_huffman_decode_table(u16 decode_table[],  uint num_syms,
 static int read_huffsym_near_end_of_input(struct input_bitstream *istream,
                                          const u16 decode_table[],
                                          const u8 lens[],
-                                         uint num_syms,
-                                         uint table_bits,
-                                         uint *n)
+                                         unsigned num_syms,
+                                         unsigned table_bits,
+                                         unsigned *n)
 {
-       uint bitsleft = istream->bitsleft;
-       uint key_size;
+       unsigned bitsleft = istream->bitsleft;
+       unsigned key_size;
        u16 sym;
        u16 key_bits;
 
@@ -394,7 +394,7 @@ int read_huffsym(struct input_bitstream *stream,
                 const u8 lengths[],
                 unsigned num_symbols,
                 unsigned table_bits,
-                uint *n,
+                unsigned *n,
                 unsigned max_codeword_len)
 {
        /* In the most common case, there are at least max_codeword_len bits
index 2926c128f0df0b9c7eb3128e4cedf8a5ade53665..d279874627aa1b2577fbeac0d9283d3f08c4471d 100644 (file)
@@ -52,7 +52,7 @@
  * The AND operation guarantees that only 3 characters will affect the hash
  * value, so every identical 3-character string will have the same hash value.
  */
-static inline uint update_hash(uint hash, u8 c)
+static inline unsigned update_hash(unsigned hash, u8 c)
 {
        return ((hash << HASH_SHIFT) ^ c) & HASH_MASK;
 }
@@ -70,8 +70,9 @@ static inline uint update_hash(uint hash, u8 c)
  * to walk through the hash chain, until the special index `0' is reached,
  * indicating the end of the hash chain.
  */
-static inline uint insert_string(u16 hash_tab[], u16 prev_tab[],
-                                const u8 window[], uint str_pos, uint hash)
+static inline unsigned insert_string(u16 hash_tab[], u16 prev_tab[],
+                                    const u8 window[], unsigned str_pos,
+                                    unsigned hash)
 {
        hash = update_hash(hash, window[str_pos + LZ_MIN_MATCH - 1]);
        prev_tab[str_pos] = hash_tab[hash];
@@ -101,21 +102,21 @@ static inline uint insert_string(u16 hash_tab[], u16 prev_tab[],
  *
  * Returns the length of the match that was found.
  */
-static uint longest_match(const u8 window[], uint bytes_remaining,
-                         uint strstart, const u16 prev_tab[],
-                         uint cur_match, uint prev_len,
-                         uint *match_start_ret,
-                         const struct lz_params *params)
+static unsigned longest_match(const u8 window[], unsigned bytes_remaining,
+                             unsigned strstart, const u16 prev_tab[],
+                             unsigned cur_match, unsigned prev_len,
+                             unsigned *match_start_ret,
+                             const struct lz_params *params)
 {
-       uint chain_len = params->max_chain_len;
+       unsigned chain_len = params->max_chain_len;
 
        const u8 *scan = window + strstart;
        const u8 *match;
-       uint len;
-       uint best_len = prev_len;
-       uint match_start = cur_match;
+       unsigned len;
+       unsigned best_len = prev_len;
+       unsigned match_start = cur_match;
 
-       uint nice_match = min(params->nice_match, bytes_remaining);
+       unsigned nice_match = min(params->nice_match, bytes_remaining);
 
        const u8 *strend = scan + min(params->max_match, bytes_remaining);
 
@@ -209,20 +210,24 @@ static uint longest_match(const u8 window[], uint bytes_remaining,
  * is the number of slots in @match_tab that have been filled with the
  * intermediate representation of a match or literal byte.
  */
-uint lz_analyze_block(const u8 uncompressed_data[], uint uncompressed_len,
-                     u32 match_tab[], lz_record_match_t record_match,
-                     lz_record_literal_t record_literal, void *record_match_arg1,
-                     void *record_match_arg2, void *record_literal_arg,
-                     const struct lz_params *params)
+unsigned lz_analyze_block(const u8 uncompressed_data[],
+                         unsigned uncompressed_len,
+                         u32 match_tab[],
+                         lz_record_match_t record_match,
+                         lz_record_literal_t record_literal,
+                         void *record_match_arg1,
+                         void *record_match_arg2,
+                         void *record_literal_arg,
+                         const struct lz_params *params)
 {
-       uint cur_match_pos = 0;
-       uint cur_input_pos = 0;
-       uint hash          = 0;
-       uint hash_head     = 0;
-       uint prev_len      = params->min_match - 1;
-       uint prev_start;
-       uint match_len     = params->min_match - 1;
-       uint match_start   = 0;
+       unsigned cur_match_pos = 0;
+       unsigned cur_input_pos = 0;
+       unsigned hash          = 0;
+       unsigned hash_head     = 0;
+       unsigned prev_len      = params->min_match - 1;
+       unsigned prev_start;
+       unsigned match_len     = params->min_match - 1;
+       unsigned match_start   = 0;
        bool match_available = false;
        u16 hash_tab[HASH_SIZE];
        u32 match;
@@ -275,7 +280,7 @@ uint lz_analyze_block(const u8 uncompressed_data[], uint uncompressed_len,
                if (prev_len >= params->min_match && match_len <= prev_len) {
 
                        /* Do not insert strings in hash table beyond this. */
-                       uint max_insert = uncompressed_len - params->min_match;
+                       unsigned max_insert = uncompressed_len - params->min_match;
 
                        /*DEBUG("Recording match (pos = %u, offset = %u, len = %u)\n",*/
                                        /*cur_input_pos - 1, */
index 08b15636acdcc66ae0c440755bfc45bf276ec13e..15c68bc022f0d0e775267ccc03b850ea3abe5026 100644 (file)
@@ -44,7 +44,6 @@ typedef uint16_t u16;
 typedef uint32_t u32;
 typedef uint64_t u64;
 #endif
-typedef unsigned uint;
 
 #ifndef min
 #define min(a, b) ({ typeof(a) __a = (a); typeof(b) __b = (b); \