diff options
author | Lasse Collin <lasse.collin@tukaani.org> | 2008-06-19 16:35:08 +0300 |
---|---|---|
committer | Lasse Collin <lasse.collin@tukaani.org> | 2008-06-19 16:35:08 +0300 |
commit | 0809c46534fa5664fe35d9e98d95e87312ed130e (patch) | |
tree | 6923ece40819c97cdd786dfdb01a7904043b1026 /src/liblzma/lzma/lzma_encoder_init.c | |
parent | Comments (diff) | |
download | xz-0809c46534fa5664fe35d9e98d95e87312ed130e.tar.xz |
Add limit of lc + lp <= 4. Now we can allocate the
literal coder as part of the main LZMA encoder or
decoder structure.
Make the LZMA decoder to rely on the current internal API
to free the allocated memory in case an error occurs.
Diffstat (limited to '')
-rw-r--r-- | src/liblzma/lzma/lzma_encoder_init.c | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/src/liblzma/lzma/lzma_encoder_init.c b/src/liblzma/lzma/lzma_encoder_init.c index c925f811..21335f95 100644 --- a/src/liblzma/lzma/lzma_encoder_init.c +++ b/src/liblzma/lzma/lzma_encoder_init.c @@ -52,7 +52,6 @@ static void lzma_lzma_encoder_end(lzma_coder *coder, lzma_allocator *allocator) { lzma_lz_encoder_end(&coder->lz, allocator); - lzma_literal_end(&coder->literal_coder, allocator); lzma_free(coder, allocator); return; } @@ -69,7 +68,6 @@ lzma_lzma_encoder_init(lzma_next_coder *next, lzma_allocator *allocator, next->coder->next = LZMA_NEXT_CODER_INIT; next->coder->lz = LZMA_LZ_ENCODER_INIT; - next->coder->literal_coder = NULL; } // Validate options that aren't validated elsewhere. @@ -99,13 +97,11 @@ lzma_lzma_encoder_init(lzma_next_coder *next, lzma_allocator *allocator, // Initialize literal coder. { const lzma_ret ret = lzma_literal_init( - &next->coder->literal_coder, allocator, + &next->coder->literal_coder, options->literal_context_bits, options->literal_pos_bits); - if (ret != LZMA_OK) { - lzma_lzma_encoder_end(next->coder, allocator); + if (ret != LZMA_OK) return ret; - } } // Initialize LZ encoder. @@ -218,7 +214,10 @@ lzma_lzma_encode_properties(const lzma_options_lzma *options, uint8_t *byte) if (options->literal_context_bits > LZMA_LITERAL_CONTEXT_BITS_MAX || options->literal_pos_bits > LZMA_LITERAL_POS_BITS_MAX - || options->pos_bits > LZMA_POS_BITS_MAX) + || options->pos_bits > LZMA_POS_BITS_MAX + || options->literal_context_bits + + options->literal_pos_bits + > LZMA_LITERAL_BITS_MAX) return true; *byte = (options->pos_bits * 5 + options->literal_pos_bits) * 9 |