mirror of
https://git.tukaani.org/xz.git
synced 2024-04-04 12:36:23 +02:00
xz: Use lzma_filters_free() in forget_filter_chain().
This is a little cleaner than the previous implementation of forget_filter_chain(). It is also more consistent since lzma_str_to_filters() will always terminate the filter chain so there is no need to terminate it later in coder_set_compression_settings().
This commit is contained in:
parent
3d21da5cff
commit
072d292501
1 changed files with 11 additions and 9 deletions
|
@ -84,10 +84,9 @@ forget_filter_chain(void)
|
||||||
{
|
{
|
||||||
// Setting a preset or using --filters makes us forget
|
// Setting a preset or using --filters makes us forget
|
||||||
// the earlier custom filter chain (if any).
|
// the earlier custom filter chain (if any).
|
||||||
while (filters_count > 0) {
|
if (filters_count > 0) {
|
||||||
--filters_count;
|
lzma_filters_free(filters, NULL);
|
||||||
free(filters[filters_count].options);
|
filters_count = 0;
|
||||||
filters[filters_count].options = NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
string_to_filter_used = false;
|
string_to_filter_used = false;
|
||||||
|
@ -125,7 +124,9 @@ coder_add_filter(lzma_vli id, void *options)
|
||||||
|
|
||||||
filters[filters_count].id = id;
|
filters[filters_count].id = id;
|
||||||
filters[filters_count].options = options;
|
filters[filters_count].options = options;
|
||||||
++filters_count;
|
// Terminate the filter chain with LZMA_VLI_UNKNOWN to simplify
|
||||||
|
// implementation of forget_filter_chain().
|
||||||
|
filters[++filters_count].id = LZMA_VLI_UNKNOWN;
|
||||||
|
|
||||||
// Setting a custom filter chain makes us forget the preset options.
|
// Setting a custom filter chain makes us forget the preset options.
|
||||||
// This makes a difference if one specifies e.g. "xz -9 --lzma2 -e"
|
// This makes a difference if one specifies e.g. "xz -9 --lzma2 -e"
|
||||||
|
@ -234,11 +235,12 @@ coder_set_compression_settings(void)
|
||||||
filters[0].id = opt_format == FORMAT_LZMA
|
filters[0].id = opt_format == FORMAT_LZMA
|
||||||
? LZMA_FILTER_LZMA1 : LZMA_FILTER_LZMA2;
|
? LZMA_FILTER_LZMA1 : LZMA_FILTER_LZMA2;
|
||||||
filters[0].options = &opt_lzma;
|
filters[0].options = &opt_lzma;
|
||||||
|
|
||||||
filters_count = 1;
|
filters_count = 1;
|
||||||
}
|
|
||||||
|
|
||||||
// Terminate the filter options array.
|
// Terminate the filter options array.
|
||||||
filters[filters_count].id = LZMA_VLI_UNKNOWN;
|
filters[1].id = LZMA_VLI_UNKNOWN;
|
||||||
|
}
|
||||||
|
|
||||||
// If we are using the .lzma format, allow exactly one filter
|
// If we are using the .lzma format, allow exactly one filter
|
||||||
// which has to be LZMA1.
|
// which has to be LZMA1.
|
||||||
|
|
Loading…
Reference in a new issue