Parolin 0.7.9 6796
Console (soon DLLs) to do a tar like job
Loading...
Searching...
No Matches
index.c File Reference

Handling of .xz Indexes and some other Stream information. More...

#include "common.h"
#include "index.h"
#include "stream_flags_common.h"

Data Structures

struct  index_tree_node_s
 
struct  index_tree
 AVL tree to hold index_stream or index_group structures. More...
 
struct  index_record
 
struct  index_group
 
struct  index_stream
 
struct  lzma_index_s
 
struct  index_cat_info
 Structure to pass info to index_cat_helper() More...
 

Macros

#define INDEX_GROUP_SIZE   512
 How many Records to allocate at once.
 
#define PREALLOC_MAX   ((SIZE_MAX - sizeof(index_group)) / sizeof(index_record))
 How many Records can be allocated at once at maximum.
 

Enumerations

enum  {
  ITER_INDEX , ITER_STREAM , ITER_GROUP , ITER_RECORD ,
  ITER_METHOD
}
 Indexing for lzma_index_iter.internal[]. More...
 
enum  { ITER_METHOD_NORMAL , ITER_METHOD_NEXT , ITER_METHOD_LEFTMOST }
 Values for lzma_index_iter.internal[ITER_METHOD].s. More...
 

Functions

 LZMA_API (lzma_index *)
 
 LZMA_API (void)
 
void lzma_index_prealloc (lzma_index *i, lzma_vli records)
 
 LZMA_API (uint64_t)
 Calculate approximate memory usage of easy encoder.
 
 LZMA_API (uint32_t)
 
uint32_t lzma_index_padding_size (const lzma_index *i)
 
 LZMA_API (lzma_ret)
 
 LZMA_API (lzma_bool)
 

Detailed Description

Handling of .xz Indexes and some other Stream information.

Macro Definition Documentation

◆ INDEX_GROUP_SIZE

#define INDEX_GROUP_SIZE   512

How many Records to allocate at once.

This should be big enough to avoid making lots of tiny allocations but small enough to avoid too much unused memory at once.

◆ PREALLOC_MAX

#define PREALLOC_MAX   ((SIZE_MAX - sizeof(index_group)) / sizeof(index_record))

How many Records can be allocated at once at maximum.

Enumeration Type Documentation

◆ anonymous enum

anonymous enum

Indexing for lzma_index_iter.internal[].

Enumerator
ITER_INDEX 
ITER_STREAM 
ITER_GROUP 
ITER_RECORD 
ITER_METHOD 

◆ anonymous enum

anonymous enum

Values for lzma_index_iter.internal[ITER_METHOD].s.

Enumerator
ITER_METHOD_NORMAL 
ITER_METHOD_NEXT 
ITER_METHOD_LEFTMOST 

Function Documentation

◆ LZMA_API() [1/6]

LZMA_API ( lzma_bool )
extern

◆ LZMA_API() [2/6]

LZMA_API ( lzma_index * )
extern

◆ LZMA_API() [3/6]

LZMA_API ( lzma_ret )
extern

◆ LZMA_API() [4/6]

LZMA_API ( uint32_t )
extern

◆ LZMA_API() [5/6]

LZMA_API ( uint64_t )
extern

Calculate approximate memory usage of easy encoder.

Get the total amount of physical memory (RAM) in bytes.

Calculate approximate memory usage of multithreaded .xz encoder.

Calculate approximate decoder memory usage of a preset.

This function is a wrapper for lzma_raw_encoder_memusage().

Parameters
presetCompression preset (level and possible flags)
Returns
Number of bytes of memory required for the given preset when encoding. If an error occurs, for example due to unsupported preset, UINT64_MAX is returned.

This function is a wrapper for lzma_raw_decoder_memusage().

Parameters
presetCompression preset (level and possible flags)
Returns
Number of bytes of memory required to decompress a file that was compressed using the given preset. If an error occurs, for example due to unsupported preset, UINT64_MAX is returned.

Since doing the encoding in threaded mode doesn't affect the memory requirements of single-threaded decompressor, you can use lzma_easy_decoder_memusage(options->preset) or lzma_raw_decoder_memusage(options->filters) to calculate the decompressor memory requirements.

Parameters
optionsCompression options
Returns
Number of bytes of memory required for encoding with the given options. If an error occurs, for example due to unsupported preset or filter chain, UINT64_MAX is returned.

Calculate approximate memory usage of easy encoder.

Get the uncompressed size of the file.

Get the total size of the file.

Get the total size of the Blocks.

Get the total size of the Stream.

Get the size of the Index field as bytes.

Get the number of Blocks.

Get the number of Streams.

Calculate the memory usage of an existing lzma_index.

On disk, the size of the Index field depends on both the number of Records stored and how big values the Records store (due to variable-length integer encoding). When the Index is kept in lzma_index structure, the memory usage depends only on the number of Records/Blocks stored in the Index(es), and in case of concatenated lzma_indexes, the number of Streams. The size in RAM is almost always significantly bigger than in the encoded form on disk.

This function calculates an approximate amount of memory needed hold the given number of Streams and Blocks in lzma_index structure. This value may vary between CPU architectures and also between liblzma versions if the internal implementation is modified.

This is a shorthand for lzma_index_memusage(lzma_index_stream_count(i), lzma_index_block_count(i)).

This returns the total number of Blocks in lzma_index. To get number of Blocks in individual Streams, use lzma_index_iter.

This is needed to verify the Backward Size field in the Stream Footer.

If multiple lzma_indexes have been combined, this works as if the Blocks were in a single Stream. This is useful if you are going to combine Blocks from multiple Streams into a single new Stream.

This doesn't include the Stream Header, Stream Footer, Stream Padding, or Index fields.

When no lzma_indexes have been combined with lzma_index_cat() and there is no Stream Padding, this function is identical to lzma_index_stream_size(). If multiple lzma_indexes have been combined, this includes also the headers of each separate Stream and the possible Stream Padding fields.

Calculate approximate memory usage of easy encoder.

Get the uncompressed size of the file.

Get the total size of the file.

Get the total size of the Blocks.

Get the total size of the Stream.

Get the size of the Index field as bytes.

Get the number of Blocks.

Get the number of Streams.

Calculate the memory usage of an existing lzma_index.

On disk, the size of the Index field depends on both the number of Records stored and the size of the Records (due to variable-length integer encoding). When the Index is kept in lzma_index structure, the memory usage depends only on the number of Records/Blocks stored in the Index(es), and in case of concatenated lzma_indexes, the number of Streams. The size in RAM is almost always significantly bigger than in the encoded form on disk.

This function calculates an approximate amount of memory needed to hold the given number of Streams and Blocks in lzma_index structure. This value may vary between CPU architectures and also between liblzma versions if the internal implementation is modified.

Parameters
streamsNumber of Streams
blocksNumber of Blocks
Returns
Approximate memory in bytes needed in a lzma_index structure.

This is a shorthand for lzma_index_memusage(lzma_index_stream_count(i), lzma_index_block_count(i)).

Parameters
iPointer to lzma_index structure
Returns
Approximate memory in bytes used by the lzma_index structure.
Parameters
iPointer to lzma_index structure
Returns
Number of Streams in the lzma_index

This returns the total number of Blocks in lzma_index. To get number of Blocks in individual Streams, use lzma_index_iter.

Parameters
iPointer to lzma_index structure
Returns
Number of blocks in the lzma_index

This is needed to verify the Backward Size field in the Stream Footer.

Parameters
iPointer to lzma_index structure
Returns
Size in bytes of the Index

If multiple lzma_indexes have been combined, this works as if the Blocks were in a single Stream. This is useful if you are going to combine Blocks from multiple Streams into a single new Stream.

Parameters
iPointer to lzma_index structure
Returns
Size in bytes of the Stream (if all Blocks are combined into one Stream).

This doesn't include the Stream Header, Stream Footer, Stream Padding, or Index fields.

Parameters
iPointer to lzma_index structure
Returns
Size in bytes of all Blocks in the Stream(s)

When no lzma_indexes have been combined with lzma_index_cat() and there is no Stream Padding, this function is identical to lzma_index_stream_size(). If multiple lzma_indexes have been combined, this includes also the headers of each separate Stream and the possible Stream Padding fields.

Parameters
iPointer to lzma_index structure
Returns
Total size of the .xz file in bytes
Parameters
iPointer to lzma_index structure
Returns
Size in bytes of the uncompressed data in the file

◆ LZMA_API() [6/6]

LZMA_API ( void )
extern

◆ lzma_index_padding_size()

uint32_t lzma_index_padding_size ( const lzma_index * i)
extern

Get the size of the Index Padding field. This is needed by Index encoder and decoder, but applications should have no use for this.

◆ lzma_index_prealloc()

void lzma_index_prealloc ( lzma_index * i,
lzma_vli records )
extern

Set for how many Records to allocate memory the next time lzma_index_append() needs to allocate space for a new Record. This is used only by the Index decoder.