aboutsummaryrefslogtreecommitdiff
path: root/src/liblzma/lz/lz_encoder.c
diff options
context:
space:
mode:
authorLasse Collin <lasse.collin@tukaani.org>2009-11-14 18:59:19 +0200
committerLasse Collin <lasse.collin@tukaani.org>2009-11-14 18:59:19 +0200
commit418d64a32e8144210f98a810738fed5a897e8367 (patch)
treee3dce06dfd250fd659d922aaed914f6cc93cd2c8 /src/liblzma/lz/lz_encoder.c
parentFix wrong function name in the previous commit. (diff)
downloadxz-418d64a32e8144210f98a810738fed5a897e8367.tar.xz
Fix a design error in liblzma API.
Originally the idea was that using LZMA_FULL_FLUSH with Stream encoder would read the filter chain from the same array that was used to intialize the Stream encoder. Since most apps wouldn't use LZMA_FULL_FLUSH, most apps wouldn't need to keep the filter chain available after initializing the Stream encoder. However, due to my mistake, it actually required keeping the array always available. Since setting the new filter chain via the array used at initialization time is not a nice way to do it for a couple of reasons, this commit ditches it and introduces lzma_filters_update(). This new function replaces also the "persistent" flag used by LZMA2 (and to-be-designed Subblock filter), which was also an ugly thing to do. Thanks to Alexey Tourbin for reminding me about the problem that Stream encoder used to require keeping the filter chain allocated.
Diffstat (limited to 'src/liblzma/lz/lz_encoder.c')
-rw-r--r--src/liblzma/lz/lz_encoder.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/liblzma/lz/lz_encoder.c b/src/liblzma/lz/lz_encoder.c
index 0e7b7d1d..bf6327d8 100644
--- a/src/liblzma/lz/lz_encoder.c
+++ b/src/liblzma/lz/lz_encoder.c
@@ -475,6 +475,22 @@ lz_encoder_end(lzma_coder *coder, lzma_allocator *allocator)
}
+static lzma_ret
+lz_encoder_update(lzma_coder *coder, lzma_allocator *allocator,
+ const lzma_filter *filters_null lzma_attribute((unused)),
+ const lzma_filter *reversed_filters)
+{
+ if (coder->lz.options_update == NULL)
+ return LZMA_PROG_ERROR;
+
+ return_if_error(coder->lz.options_update(
+ coder->lz.coder, reversed_filters));
+
+ return lzma_next_filter_update(
+ &coder->next, allocator, reversed_filters + 1);
+}
+
+
extern lzma_ret
lzma_lz_encoder_init(lzma_next_coder *next, lzma_allocator *allocator,
const lzma_filter_info *filters,
@@ -495,6 +511,7 @@ lzma_lz_encoder_init(lzma_next_coder *next, lzma_allocator *allocator,
next->code = &lz_encode;
next->end = &lz_encoder_end;
+ next->update = &lz_encoder_update;
next->coder->lz.coder = NULL;
next->coder->lz.code = NULL;