add support for setting xz memlimit

Merged-by: Vitaly Chikunov <vt@altlinux.org>
This commit is contained in:
Per Øyvind Karlsen 2015-08-12 03:12:06 +02:00 committed by Vitaly Chikunov
parent c254b0d63f
commit 222d4ff7fc

View File

@ -2777,6 +2777,7 @@ static LZFILE *lzopen_internal(const char *path, const char *mode, int fd, int x
FILE *fp;
LZFILE *lzfile;
lzma_ret ret;
uint64_t mem_limit = rpmExpandNumeric("%{_xz_memlimit}");
for (; *mode; mode++) {
if (*mode == 'w')
@ -2828,7 +2829,7 @@ static LZFILE *lzopen_internal(const char *path, const char *mode, int fd, int x
/* We set the memlimit for decompression to 100MiB which should be
* more than enough to be sufficient for level 9 which requires 65 MiB.
*/
ret = lzma_auto_decoder(&lzfile->strm, 100<<20, 0);
ret = lzma_auto_decoder(&lzfile->strm, mem_limit ? mem_limit : 100<<20, 0);
}
if (ret != LZMA_OK) {
switch (ret) {