]> wimlib.net Git - wimlib/blobdiff - src/lzx_decompress.c
Implement setting of Windows-specific XML information
[wimlib] / src / lzx_decompress.c
index 1ebaf3519c8ec8dc169aa46c0737a34f6d06f71b..9a030759192caa9e63a548c8af340474c953b733 100644 (file)
@@ -498,7 +498,7 @@ lzx_decompress_block(int block_type, u8 * const out_begin,
                        match_offset -= LZX_OFFSET_ADJUSTMENT;
 
                        /* Update the match offset LRU queue.  */
-                       BUILD_BUG_ON(LZX_NUM_RECENT_OFFSETS != 3);
+                       STATIC_ASSERT(LZX_NUM_RECENT_OFFSETS == 3);
                        queue->R[2] = queue->R[1];
                        queue->R[1] = queue->R[0];
                        queue->R[0] = match_offset;
@@ -521,9 +521,9 @@ lzx_decompress_block(int block_type, u8 * const out_begin,
 }
 
 static int
-lzx_decompress(const void *compressed_data, size_t compressed_size,
-              void *uncompressed_data, size_t uncompressed_size,
-              void *_dec)
+lzx_decompress(const void *restrict compressed_data, size_t compressed_size,
+              void *restrict uncompressed_data, size_t uncompressed_size,
+              void *restrict _dec)
 {
        struct lzx_decompressor *dec = _dec;
        struct input_bitstream istream;
@@ -583,17 +583,15 @@ lzx_decompress(const void *compressed_data, size_t compressed_size,
                         * have been encoded as a literal using mainsym 0xe8. */
                        if (dec->tables.maincode_lens[0xe8] != 0)
                                may_have_e8_byte = true;
+
+                       out_next += block_size;
                } else {
 
                        /* Uncompressed block.  */
-                       const u8 *p;
-
-                       p = bitstream_read_bytes(&istream, block_size);
-                       if (!p)
+                       out_next = bitstream_read_bytes(&istream, out_next, block_size);
+                       if (!out_next)
                                return -1;
 
-                       memcpy(out_next, p, block_size);
-
                        /* Re-align the bitstream if an odd number of bytes was
                         * read.  */
                        if (block_size & 1)
@@ -601,13 +599,11 @@ lzx_decompress(const void *compressed_data, size_t compressed_size,
 
                        may_have_e8_byte = true;
                }
-
-               out_next += block_size;
        }
 
        /* Postprocess the data unless it cannot possibly contain 0xe8 bytes  */
        if (may_have_e8_byte)
-               lzx_undo_e8_preprocessing(uncompressed_data, uncompressed_size);
+               lzx_postprocess(uncompressed_data, uncompressed_size);
 
        return 0;
 }