liblzma (XZ Utils): lzma_stream Struct Reference

liblzma (XZ Utils) 5.6.3

- Main Page
- Data Structures
- Files

- Data Structures
- Data Fields

Data Fields
lzma_stream Struct Reference

Passing data to and from liblzma. More...

`#include <base.h>`

## Data Fields
const uint8_t * | next_in
size_t | avail_in
uint64_t | total_in
uint8_t * | next_out
size_t | avail_out
uint64_t | total_out
const lzma_allocator * | allocator
| Custom memory allocation functions.
lzma_internal * | internal
uint64_t | seek_pos
| New seek input position for LZMA_SEEK_NEEDED.

## Detailed Description

Passing data to and from liblzma.

The lzma_stream structure is used for

- passing pointers to input and output buffers to liblzma;
- defining custom memory handler functions; and
- holding a pointer to coder-specific internal data structures.

Typical usage:

- After allocating lzma_stream (on stack or with malloc()), it must be initialized to LZMA_STREAM_INIT (see LZMA_STREAM_INIT for details).
- Initialize a coder to the lzma_stream, for example by using lzma_easy_encoder() or lzma_auto_decoder(). Some notes:
  - In contrast to zlib, strm->next_in and strm->next_out are ignored by all initialization functions, thus it is safe to not initialize them yet.
  - The initialization functions always set strm->total_in and strm->total_out to zero.
  - If the initialization function fails, no memory is left allocated that would require freeing with lzma_end() even if some memory was associated with the lzma_stream structure when the initialization function was called.
- Use lzma_code() to do the actual work.
- Once the coding has been finished, the existing lzma_stream can be reused. It is OK to reuse lzma_stream with different initialization function without calling lzma_end() first. Old allocations are automatically freed.
- Finally, use lzma_end() to free the allocated memory. lzma_end() never frees the lzma_stream structure itself.

Application may modify the values of total_in and total_out as it wants. They are updated by liblzma to match the amount of data read and written but aren't used for anything else except as a possible return values from lzma_get_progress().

## Field Documentation

## ◆ next_in

const uint8_t* lzma_stream::next_in

Pointer to the next input byte.

## ◆ avail_in

size_t lzma_stream::avail_in

Number of available input bytes in next_in.

## ◆ total_in

uint64_t lzma_stream::total_in

Total number of bytes read by liblzma.

## ◆ next_out

uint8_t* lzma_stream::next_out

Pointer to the next output position.

## ◆ avail_out

size_t lzma_stream::avail_out

Amount of free space in next_out.

## ◆ total_out

uint64_t lzma_stream::total_out

Total number of bytes written by liblzma.

## ◆ allocator

const lzma_allocator* lzma_stream::allocator

Custom memory allocation functions.

In most cases this is NULL which makes liblzma use the standard malloc() and free().

Note
  In 5.0.x this is not a const pointer.

## ◆ internal

lzma_internal* lzma_stream::internal

Internal state is not visible to applications.

## ◆ seek_pos

uint64_t lzma_stream::seek_pos

New seek input position for LZMA_SEEK_NEEDED.

When lzma_code() returns LZMA_SEEK_NEEDED, the new input position needed by liblzma will be available seek_pos. The value is guaranteed to not exceed the file size that was specified when this lzma_stream was initialized.

In all other situations the value of this variable is undefined.

The documentation for this struct was generated from the following file:

- lzma/base.h