mirror of https://git.tukaani.org/xz.git
Fix _memconfig() functions.
This affects lzma_memusage() and lzma_memlimit_get().
This commit is contained in:
parent
1a7ec87c8e
commit
8ea8dc754a
|
@ -615,13 +615,6 @@ extern LZMA_API(lzma_ret) lzma_index_encoder(
|
|||
* - LZMA_MEM_ERROR
|
||||
* - LZMA_MEMLIMIT_ERROR
|
||||
* - LZMA_PROG_ERROR
|
||||
*
|
||||
* \note The memory usage limit is checked early in the decoding
|
||||
* (within the first dozen input bytes or so). The actual memory
|
||||
* is allocated later in smaller pieces. If the memory usage
|
||||
* limit is modified with lzma_memlimit_set() after a part
|
||||
* of the Index has already been decoded, the new limit may
|
||||
* get ignored.
|
||||
*/
|
||||
extern LZMA_API(lzma_ret) lzma_index_decoder(
|
||||
lzma_stream *strm, lzma_index **i, uint64_t memlimit)
|
||||
|
|
|
@ -173,12 +173,15 @@ static lzma_ret
|
|||
alone_decoder_memconfig(lzma_coder *coder, uint64_t *memusage,
|
||||
uint64_t *old_memlimit, uint64_t new_memlimit)
|
||||
{
|
||||
if (new_memlimit != 0 && new_memlimit < coder->memusage)
|
||||
return LZMA_MEMLIMIT_ERROR;
|
||||
|
||||
*memusage = coder->memusage;
|
||||
*old_memlimit = coder->memlimit;
|
||||
coder->memlimit = new_memlimit;
|
||||
|
||||
if (new_memlimit != 0) {
|
||||
if (new_memlimit < coder->memusage)
|
||||
return LZMA_MEMLIMIT_ERROR;
|
||||
|
||||
coder->memlimit = new_memlimit;
|
||||
}
|
||||
|
||||
return LZMA_OK;
|
||||
}
|
||||
|
|
|
@ -219,12 +219,14 @@ index_decoder_memconfig(lzma_coder *coder, uint64_t *memusage,
|
|||
uint64_t *old_memlimit, uint64_t new_memlimit)
|
||||
{
|
||||
*memusage = lzma_index_memusage(1, coder->count);
|
||||
|
||||
if (new_memlimit != 0 && new_memlimit < *memusage)
|
||||
return LZMA_MEMLIMIT_ERROR;
|
||||
|
||||
*old_memlimit = coder->memlimit;
|
||||
coder->memlimit = new_memlimit;
|
||||
|
||||
if (new_memlimit != 0) {
|
||||
if (new_memlimit < *memusage)
|
||||
return LZMA_MEMLIMIT_ERROR;
|
||||
|
||||
coder->memlimit = new_memlimit;
|
||||
}
|
||||
|
||||
return LZMA_OK;
|
||||
}
|
||||
|
|
|
@ -383,12 +383,15 @@ static lzma_ret
|
|||
stream_decoder_memconfig(lzma_coder *coder, uint64_t *memusage,
|
||||
uint64_t *old_memlimit, uint64_t new_memlimit)
|
||||
{
|
||||
if (new_memlimit != 0 && new_memlimit < coder->memusage)
|
||||
return LZMA_MEMLIMIT_ERROR;
|
||||
|
||||
*memusage = coder->memusage;
|
||||
*old_memlimit = coder->memlimit;
|
||||
coder->memlimit = new_memlimit;
|
||||
|
||||
if (new_memlimit != 0) {
|
||||
if (new_memlimit < coder->memusage)
|
||||
return LZMA_MEMLIMIT_ERROR;
|
||||
|
||||
coder->memlimit = new_memlimit;
|
||||
}
|
||||
|
||||
return LZMA_OK;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue