]> wimlib.net Git - wimlib/blobdiff - src/lzx_decompress.c
Use 'restrict' on pointer arguments to all compress() and decompress() functions
[wimlib] / src / lzx_decompress.c
index 1ebaf3519c8ec8dc169aa46c0737a34f6d06f71b..a8fbcd7d5e8325542537730ec7fef328754c53a8 100644 (file)
@@ -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,8 +599,6 @@ 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  */