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;
}
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;
* 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)
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;
}