diff options
author | Lasse Collin <lasse.collin@tukaani.org> | 2008-12-27 19:27:49 +0200 |
---|---|---|
committer | Lasse Collin <lasse.collin@tukaani.org> | 2008-12-27 19:27:49 +0200 |
commit | e33194e79d8f5ce07cb4aca909b324ae75098f7e (patch) | |
tree | 6a1db024ccdbe49ea8d03dacf9ab0ebcedaa6688 /src/liblzma/common/alone_encoder.c | |
parent | Updated Makefile.am that was missing from the previous commit. (diff) | |
download | xz-e33194e79d8f5ce07cb4aca909b324ae75098f7e.tar.xz |
Bunch of liblzma tweaks, including some API changes.
The API and ABI should now be very close to stable,
although the code behind it isn't yet.
Diffstat (limited to '')
-rw-r--r-- | src/liblzma/common/alone_encoder.c | 22 |
1 files changed, 9 insertions, 13 deletions
diff --git a/src/liblzma/common/alone_encoder.c b/src/liblzma/common/alone_encoder.c index 41fb6162..b2dccf05 100644 --- a/src/liblzma/common/alone_encoder.c +++ b/src/liblzma/common/alone_encoder.c @@ -104,28 +104,24 @@ alone_encoder_init(lzma_next_coder *next, lzma_allocator *allocator, // Encode the header: // - Properties (1 byte) if (lzma_lzma_lclppb_encode(options, next->coder->header)) - return LZMA_PROG_ERROR; + return LZMA_OPTIONS_ERROR; - // - Dictionary size (4 bytes); limit to 1 GiB since that's what - // LZMA SDK currently does for encoding. - if (options->dict_size < LZMA_DICT_SIZE_MIN - || options->dict_size > (UINT32_C(1) << 30)) - return LZMA_PROG_ERROR; + // - Dictionary size (4 bytes) + if (options->dict_size < LZMA_DICT_SIZE_MIN) + return LZMA_OPTIONS_ERROR; // Round up to to the next 2^n or 2^n + 2^(n - 1) depending on which - // one is the next. While the header would allow any 32-bit integer, - // we do this to keep the decoder of liblzma accepting the resulting - // files. - // - // FIXME Maybe LZMA_Alone needs some lower limit for maximum - // dictionary size? Must check decoders from old LZMA SDK version. + // one is the next unless it is UINT32_MAX. While the header would + // allow any 32-bit integer, we do this to keep the decoder of liblzma + // accepting the resulting files. uint32_t d = options->dict_size - 1; d |= d >> 2; d |= d >> 3; d |= d >> 4; d |= d >> 8; d |= d >> 16; - ++d; + if (d != UINT32_MAX) + ++d; integer_write_32(next->coder->header + 1, d); |