X-Git-Url: https://wimlib.net/git/?p=wimlib;a=blobdiff_plain;f=include%2Fwimlib%2Fdecompress_common.h;fp=include%2Fwimlib%2Fdecompress_common.h;h=99930b940f9a09053c5796c8acdc87b35a5478ad;hp=3f3742a02ea750aad757febe523109b9441954d6;hb=f2d037631917ea7149697f1fab14bdd726440d2c;hpb=b0257a60d3e107a2b39603e3f7ad9cb6bc1e487d diff --git a/include/wimlib/decompress_common.h b/include/wimlib/decompress_common.h index 3f3742a0..99930b94 100644 --- a/include/wimlib/decompress_common.h +++ b/include/wimlib/decompress_common.h @@ -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)