i++;
continue;
}
- rel_offset = to_le32(*(int32_t*)(uncompressed_data + i + 1));
+ rel_offset = le32_to_cpu(*(int32_t*)(uncompressed_data + i + 1));
if (rel_offset >= -i && rel_offset < file_size) {
if (rel_offset < file_size - i) {
/* "compensating translation" */
abs_offset = rel_offset - file_size;
}
- *(int32_t*)(uncompressed_data + i + 1) = to_le32(abs_offset);
+ *(int32_t*)(uncompressed_data + i + 1) = cpu_to_le32(abs_offset);
}
i += 5;
}
static const struct lz_params lzx_lz_params = {
+
+ /* LZX_MIN_MATCH == 2, but 2-character matches are rarely useful; the
+ * minimum match for compression is set to 3 instead. */
.min_match = 3,
+
.max_match = LZX_MAX_MATCH,
.good_match = LZX_MAX_MATCH,
.nice_match = LZX_MAX_MATCH,
uint compressed_len;
uint i;
int ret;
+ int block_type = LZX_BLOCKTYPE_ALIGNED;
LZX_DEBUG("uncompressed_len = %u", uncompressed_len);
/* The first three bits tell us what kind of block it is, and are one
* of the LZX_BLOCKTYPE_* values. */
- bitstream_put_bits(&ostream, LZX_BLOCKTYPE_ALIGNED, 3);
+ bitstream_put_bits(&ostream, block_type, 3);
/* The next bit indicates whether the block size is the default (32768),
* indicated by a 1 bit, or whether the block size is given by the next
/* Write out the aligned offset tree. Note that M$ lies and says that
* the aligned offset tree comes after the length tree, but that is
* wrong; it actually is before the main tree. */
- for (i = 0; i < LZX_ALIGNEDTREE_NUM_SYMBOLS; i++)
- bitstream_put_bits(&ostream, codes.aligned_lens[i],
- LZX_ALIGNEDTREE_ELEMENT_SIZE);
+ if (block_type == LZX_BLOCKTYPE_ALIGNED)
+ for (i = 0; i < LZX_ALIGNEDTREE_NUM_SYMBOLS; i++)
+ bitstream_put_bits(&ostream, codes.aligned_lens[i],
+ LZX_ALIGNEDTREE_ELEMENT_SIZE);
/* Write the pre-tree and lengths for the first LZX_NUM_CHARS symbols in the
* main tree. */
return ret;
/* Write the compressed literals. */
- ret = lzx_write_compressed_literals(&ostream, LZX_BLOCKTYPE_ALIGNED,
+ ret = lzx_write_compressed_literals(&ostream, block_type,
match_tab, num_matches, &codes);
if (ret != 0)
return ret;