Validate Index by using a hash function.
- Note
- Never include this file directly. Use <lzma.h> instead.
Hashing makes it possible to use constant amount of memory to validate Index of arbitrary size.
Allocate and initialize a new lzma_index_hash structure.
If index_hash is NULL, this function allocates and initializes a new lzma_index_hash structure and returns a pointer to it. If allocation fails, NULL is returned.
If index_hash is non-NULL, this function reinitializes the lzma_index_hash structure and returns the same pointer. In this case, return value cannot be NULL or a different pointer than the index_hash that was given as an argument.
- Parameters
-
index_hash | Pointer to a lzma_index_hash structure or NULL. |
allocator | lzma_allocator for custom allocator functions. Set to NULL to use malloc() and free(). |
- Returns
- Initialized lzma_index_hash structure on success or NULL on failure.
lzma_ret lzma_index_hash_decode |
( |
lzma_index_hash * |
index_hash, |
|
|
const uint8_t * |
in, |
|
|
size_t * |
in_pos, |
|
|
size_t |
in_size |
|
) |
| |
|
extern |
Decode and validate the Index field.
After telling the sizes of all Blocks with lzma_index_hash_append(), the actual Index field is decoded with this function. Specifically, once decoding of the Index field has been started, no more Records can be added using lzma_index_hash_append().
This function doesn't use lzma_stream structure to pass the input data. Instead, the input buffer is specified using three arguments. This is because it matches better the internal APIs of liblzma.
- Parameters
-
| index_hash | Pointer to a lzma_index_hash structure |
| in | Pointer to the beginning of the input buffer |
[out] | in_pos | in[*in_pos] is the next byte to process |
| in_size | in[in_size] is the first byte not to process |
- Returns
- Possible lzma_ret values:
- LZMA_OK: So far good, but more input is needed.
- LZMA_STREAM_END: Index decoded successfully and it matches the Records given with lzma_index_hash_append().
- LZMA_DATA_ERROR: Index is corrupt or doesn't match the information given with lzma_index_hash_append().
- LZMA_BUF_ERROR: Cannot progress because *in_pos >= in_size.
- LZMA_PROG_ERROR