diff options
author | Lasse Collin <lasse.collin@tukaani.org> | 2009-12-31 22:45:53 +0200 |
---|---|---|
committer | Lasse Collin <lasse.collin@tukaani.org> | 2009-12-31 22:45:53 +0200 |
commit | 1a7ec87c8ee61dfc2e496d2e1fb7ab0939804691 (patch) | |
tree | 3ed5d9cc0c7629c1ca09a5df1d1193b90815cc88 /src/liblzma/common/index_decoder.c | |
parent | Remove c-format tag in cs.po. (diff) | |
download | xz-1a7ec87c8ee61dfc2e496d2e1fb7ab0939804691.tar.xz |
Revised the Index handling code.
This breaks API and ABI but most apps are not affected
since most apps don't use this part of the API. You will
get a compile error if you are using anything that got
broken.
Summary of changes:
- Ability to store Stream Flags, which are needed
for random-access reading in multi-Stream files.
- Separate function to set size of Stream Padding.
- Iterator structure makes it possible to read the same
lzma_index from multiple threads at the same time.
- A lot faster code to locate Blocks.
- Removed lzma_index_equal() without adding anything
to replace it. I don't know what it should do exactly
with the new features and what actually needs this
function in the first place other than test_index.c,
which now has its own code to compare lzma_indexes.
Diffstat (limited to 'src/liblzma/common/index_decoder.c')
-rw-r--r-- | src/liblzma/common/index_decoder.c | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/src/liblzma/common/index_decoder.c b/src/liblzma/common/index_decoder.c index 258bf023..a3ea791f 100644 --- a/src/liblzma/common/index_decoder.c +++ b/src/liblzma/common/index_decoder.c @@ -95,11 +95,15 @@ index_decode(lzma_coder *coder, lzma_allocator *allocator, // Fall through case SEQ_MEMUSAGE: - if (lzma_index_memusage(coder->count) > coder->memlimit) { + if (lzma_index_memusage(1, coder->count) > coder->memlimit) { ret = LZMA_MEMLIMIT_ERROR; goto out; } + // Tell the Index handling code how many Records this + // Index has to allow it to allocate memory more efficiently. + lzma_index_prealloc(coder->index, coder->count); + ret = LZMA_OK; coder->sequence = coder->count == 0 ? SEQ_PADDING_INIT : SEQ_UNPADDED; @@ -214,7 +218,7 @@ static lzma_ret index_decoder_memconfig(lzma_coder *coder, uint64_t *memusage, uint64_t *old_memlimit, uint64_t new_memlimit) { - *memusage = lzma_index_memusage(coder->count); + *memusage = lzma_index_memusage(1, coder->count); if (new_memlimit != 0 && new_memlimit < *memusage) return LZMA_MEMLIMIT_ERROR; @@ -238,7 +242,7 @@ index_decoder_reset(lzma_coder *coder, lzma_allocator *allocator, *i = NULL; // We always allocate a new lzma_index. - coder->index = lzma_index_init(NULL, allocator); + coder->index = lzma_index_init(allocator); if (coder->index == NULL) return LZMA_MEM_ERROR; @@ -329,7 +333,7 @@ lzma_index_buffer_decode( } else if (ret == LZMA_MEMLIMIT_ERROR) { // Tell the caller how much memory would have // been needed. - *memlimit = lzma_index_memusage(coder.count); + *memlimit = lzma_index_memusage(1, coder.count); } } |