Rizin
unix-like reverse engineering framework and cli tools
|
Handling of .xz Indexes and some other Stream information. More...
Go to the source code of this file.
Classes | |
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. More... | |
#define | PREALLOC_MAX ((SIZE_MAX - sizeof(index_group)) / sizeof(index_record)) |
How many Records can be allocated at once at maximum. More... | |
Typedefs | |
typedef struct index_tree_node_s | index_tree_node |
Base structure for index_stream and index_group structures. More... | |
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... | |
#define INDEX_GROUP_SIZE 512 |
#define PREALLOC_MAX ((SIZE_MAX - sizeof(index_group)) / sizeof(index_record)) |
typedef struct index_tree_node_s index_tree_node |
Base structure for index_stream and index_group structures.
anonymous enum |
Indexing for lzma_index_iter.internal[].
Enumerator | |
---|---|
ITER_INDEX | |
ITER_STREAM | |
ITER_GROUP | |
ITER_RECORD | |
ITER_METHOD |
Definition at line 960 of file index.c.
anonymous enum |
Values for lzma_index_iter.internal[ITER_METHOD].s.
Enumerator | |
---|---|
ITER_METHOD_NORMAL | |
ITER_METHOD_NEXT | |
ITER_METHOD_LEFTMOST |
Definition at line 970 of file index.c.
|
static |
Add the Stream nodes from the source index to dest using recursion. Simplest iterative traversal of the source tree wouldn't work, because we update the pointers in nodes when moving them to the destination tree.
Definition at line 745 of file index.c.
References index_tree_node_s::compressed_base, index_tree_append(), info(), index_tree_node_s::left, NULL, index_tree_node_s::right, and index_tree_node_s::uncompressed_base.
|
static |
Duplicate an index_stream.
Definition at line 865 of file index.c.
References index_group::allocated, allocator, assert(), index_tree_node_s::compressed_base, dest, i, lzma_index_s::index_list_size, index_stream_end(), index_stream_init(), index_tree_append(), index_tree_next(), index_group::last, lzma_alloc(), memcpy(), index_group::node, NULL, index_group::number_base, PREALLOC_MAX, lzma_index_s::record_count, index_group::records, src, and index_tree_node_s::uncompressed_base.
Referenced by LZMA_API().
|
static |
Definition at line 536 of file index.c.
References index_size(), LZMA_STREAM_HEADER_SIZE, LZMA_VLI_MAX, LZMA_VLI_UNKNOWN, stream_padding, and vli_ceil4().
|
static |
Definition at line 380 of file index.c.
References allocator, lzma_index_s::checks, i, INDEX_GROUP_SIZE, lzma_index_s::index_list_size, index_tree_init(), lzma_alloc(), NULL, lzma_index_s::prealloc, lzma_index_s::record_count, lzma_index_s::streams, lzma_index_s::total_size, and lzma_index_s::uncompressed_size.
Referenced by LZMA_API().
|
static |
Free the memory allocated for a Stream and its Record groups.
Definition at line 370 of file index.c.
References allocator, index_tree_end(), lzma_free(), and s.
Referenced by index_dup_stream(), and LZMA_API().
|
static |
Allocate and initialize a new Stream using the given base offsets.
Definition at line 340 of file index.c.
References allocator, index_tree_init(), lzma_alloc(), NULL, s, and UINT32_MAX.
Referenced by index_dup_stream(), and LZMA_API().
|
static |
Add a new node to the tree. node->uncompressed_base and node->compressed_base must have been set by the caller already.
Definition at line 230 of file index.c.
References assert(), bsr32(), index_tree_node_s::compressed_base, index_tree::count, ctz32(), index_tree_node_s::left, index_tree::leftmost, NULL, index_tree_node_s::parent, index_tree_node_s::right, index_tree::rightmost, index_tree::root, UINT32_C, and index_tree_node_s::uncompressed_base.
Referenced by index_cat_helper(), index_dup_stream(), and LZMA_API().
|
static |
Free the memory allocated for a tree. Each node is freed using the given free_func which is either &lzma_free or &index_stream_end. The latter is used to free the Record groups from each index_stream before freeing the index_stream itself.
Definition at line 215 of file index.c.
References allocator, assert(), index_tree_node_end(), NULL, and index_tree::root.
Referenced by index_stream_end(), and LZMA_API().
|
static |
Definition at line 182 of file index.c.
References index_tree::count, index_tree::leftmost, NULL, index_tree::rightmost, and index_tree::root.
Referenced by index_init_plain(), and index_stream_init().
|
static |
Locate a node that contains the given uncompressed offset. It is caller's job to check that target is not bigger than the uncompressed size of the tree (the last node would be returned in that case still).
Definition at line 315 of file index.c.
References assert(), index_tree_node_s::left, index_tree::leftmost, NULL, index_tree_node_s::right, index_tree::root, and index_tree_node_s::uncompressed_base.
Referenced by LZMA_API().
|
static |
Get the next node in the tree. Return NULL if there are no more nodes.
Definition at line 294 of file index.c.
References index_tree_node_s::left, NULL, index_tree_node_s::parent, and index_tree_node_s::right.
Referenced by index_dup_stream(), and LZMA_API().
|
static |
Helper for index_tree_end()
Definition at line 194 of file index.c.
References allocator, and NULL.
Referenced by index_tree_end().
|
static |
Definition at line 978 of file index.c.
References assert(), index_tree_node_s::compressed_base, g, i, index_size(), ITER_GROUP, ITER_INDEX, ITER_METHOD, ITER_METHOD_LEFTMOST, ITER_METHOD_NEXT, ITER_METHOD_NORMAL, ITER_RECORD, ITER_STREAM, LZMA_STREAM_HEADER_SIZE, index_group::node, NULL, index_group::number_base, index_tree_node_s::parent, index_group::records, index_tree_node_s::right, index_tree::rightmost, lzma_index_s::streams, UINT32_MAX, index_tree_node_s::uncompressed_base, index_record::uncompressed_sum, index_record::unpadded_sum, and vli_ceil4().
Referenced by LZMA_API().
LZMA_API | ( | lzma_bool | ) |
Definition at line 1102 of file index.c.
References i, index_tree_next(), ITER_GROUP, ITER_INDEX, ITER_METHOD, ITER_METHOD_LEFTMOST, ITER_METHOD_NEXT, ITER_METHOD_NORMAL, ITER_RECORD, iter_set_info(), ITER_STREAM, index_tree::leftmost, LZMA_INDEX_ITER_BLOCK, LZMA_INDEX_ITER_NONEMPTY_BLOCK, LZMA_INDEX_ITER_STREAM, index_group::node, NULL, index_group::records, lzma_index_s::streams, index_tree_node_s::uncompressed_base, and index_record::uncompressed_sum.
LZMA_API | ( | lzma_index * | ) |
Definition at line 397 of file index.c.
References allocator, i, index_init_plain(), index_stream_init(), index_tree_append(), lzma_free(), NULL, s, and lzma_index_s::streams.
LZMA_API | ( | lzma_ret | ) |
Definition at line 600 of file index.c.
References i, LZMA_OK, LZMA_PROG_ERROR, NULL, return_if_error, index_tree::rightmost, s, and lzma_index_s::streams.
LZMA_API | ( | uint32_t | ) |
Definition at line 578 of file index.c.
References lzma_index_s::checks, checks, i, index_tree::rightmost, s, lzma_index_s::streams, UINT32_C, and UINT32_MAX.
LZMA_API | ( | uint64_t | ) |
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().
preset | Compression preset (level and possible flags) |
This function is a wrapper for lzma_raw_decoder_memusage().
preset | Compression preset (level and possible flags) |
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.
options | Compression options |
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.
Definition at line 441 of file index.c.
References blocks, make_dist_html::groups, INDEX_GROUP_SIZE, limit, LZMA_VLI_MAX, streams, UINT32_MAX, and UINT64_MAX.
LZMA_API | ( | void | ) |
Definition at line 416 of file index.c.
References allocator, i, index_stream_end(), index_tree_end(), lzma_free(), NULL, and lzma_index_s::streams.
uint32_t lzma_index_padding_size | ( | const lzma_index * | i | ) |
Get the size of the Index Padding field. This is needed by Index encoder and decoder, but applications should have no use for this.
Definition at line 593 of file index.c.
References i, lzma_index_s::index_list_size, index_size_unpadded(), LZMA_VLI_C, and lzma_index_s::record_count.
Referenced by index_decode(), and index_encode().
void lzma_index_prealloc | ( | lzma_index * | i, |
lzma_vli | records | ||
) |
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.
Definition at line 431 of file index.c.
References i, lzma_index_s::prealloc, and PREALLOC_MAX.
Referenced by index_decode().