XZ Utils 5.4.0
Functions | Variables
filter_common.c File Reference

Filter-specific stuff common for both encoder and decoder. More...

#include "filter_common.h"

Functions

lzma_ret lzma_filters_copy (const lzma_filter *src, lzma_filter *real_dest, const lzma_allocator *allocator)
 Copy the filters array. More...
 
void lzma_filters_free (lzma_filter *filters, const lzma_allocator *allocator)
 Free the options in the array of lzma_filter structures. More...
 
lzma_ret lzma_validate_chain (const lzma_filter *filters, size_t *count)
 
lzma_ret lzma_raw_coder_init (lzma_next_coder *next, const lzma_allocator *allocator, const lzma_filter *options, lzma_filter_find coder_find, bool is_encoder)
 
uint64_t lzma_raw_coder_memusage (lzma_filter_find coder_find, const lzma_filter *filters)
 

Variables

struct {
   lzma_vli   id
 Filter ID. More...
 
   size_t   options_size
 Size of the filter-specific options structure. More...
 
   bool   non_last_ok
 
   bool   last_ok
 
   bool   changes_size
 
features []
 

Detailed Description

Filter-specific stuff common for both encoder and decoder.

Function Documentation

◆ lzma_filters_copy()

lzma_ret lzma_filters_copy ( const lzma_filter src,
lzma_filter dest,
const lzma_allocator allocator 
)

Copy the filters array.

Copy the Filter IDs and filter-specific options from src to dest. Up to LZMA_FILTERS_MAX filters are copied, plus the terminating .id == LZMA_VLI_UNKNOWN. Thus, dest should have at least LZMA_FILTERS_MAX + 1 elements space unless the caller knows that src is smaller than that.

Unless the filter-specific options is NULL, the Filter ID has to be supported by liblzma, because liblzma needs to know the size of every filter-specific options structure. The filter-specific options are not validated. If options is NULL, any unsupported Filter IDs are copied without returning an error.

Old filter-specific options in dest are not freed, so dest doesn't need to be initialized by the caller in any way.

If an error occurs, memory possibly already allocated by this function is always freed. liblzma versions older than 5.2.7 may modify the dest array and leave its contents in an undefined state if an error occurs. liblzma 5.2.7 and newer only modify the dest array when returning LZMA_OK.

Returns
- LZMA_OK
  • LZMA_MEM_ERROR
  • LZMA_OPTIONS_ERROR: Unsupported Filter ID and its options is not NULL.
  • LZMA_PROG_ERROR: src or dest is NULL.

◆ lzma_filters_free()

void lzma_filters_free ( lzma_filter filters,
const lzma_allocator allocator 
)

Free the options in the array of lzma_filter structures.

This frees the filter chain options. The filters array itself is not freed.

The filters array must have at most LZMA_FILTERS_MAX + 1 elements including the terminating element which must have .id = LZMA_VLI_UNKNOWN. For all elements before the terminating element:

  • options will be freed using the given lzma_allocator or, if allocator is NULL, using free().
  • options will be set to NULL.
  • id will be set to LZMA_VLI_UNKNOWN.

If filters is NULL, this does nothing but remember that this never frees the filters array itself.

Variable Documentation

◆ id

Filter ID.

◆ options_size

size_t options_size

Size of the filter-specific options structure.

◆ non_last_ok

bool non_last_ok

True if it is OK to use this filter as non-last filter in the chain.

◆ last_ok

bool last_ok

True if it is OK to use this filter as the last filter in the chain.

◆ changes_size

bool changes_size

True if the filter may change the size of the data (that is, the amount of encoded output can be different than the amount of uncompressed input).