]> wimlib.net Git - wimlib/blobdiff - include/wimlib/decompress_common.h
cleanups
[wimlib] / include / wimlib / decompress_common.h
index 3f3742a02ea750aad757febe523109b9441954d6..867e84a09993e3a7b1af33d818c2e309fb000bfe 100644 (file)
@@ -131,11 +131,24 @@ bitstream_read_bits(struct input_bitstream *is, unsigned num_bits)
 static inline u8
 bitstream_read_byte(struct input_bitstream *is)
 {
-       if (unlikely(is->end - is->next < 1))
+       if (unlikely(is->end == is->next))
                return 0;
        return *is->next++;
 }
 
+/* Read and return the next 16-bit integer embedded in the bitstream.  */
+static inline u16
+bitstream_read_u16(struct input_bitstream *is)
+{
+       u16 v;
+
+       if (unlikely(is->end - is->next < 2))
+               return 0;
+       v = le16_to_cpu(*(const le16 *)is->next);
+       is->next += 2;
+       return v;
+}
+
 /* Read and return the next 32-bit integer embedded in the bitstream.  */
 static inline u32
 bitstream_read_u32(struct input_bitstream *is)
@@ -208,8 +221,8 @@ static inline u16
 read_huffsym(struct input_bitstream *istream, const u16 decode_table[],
             unsigned table_bits, unsigned max_codeword_len)
 {
-       u16 entry;
-       u16 key_bits;
+       unsigned entry;
+       unsigned key_bits;
 
        bitstream_ensure_bits(istream, max_codeword_len);