Unify buffer size for lzma2 decompressor

This commit is contained in:
Abs62 2018-03-08 11:34:07 +03:00
parent 1e85a18662
commit a563311b61

View file

@ -80,14 +80,12 @@ int res;
#ifdef MAKE_ZIM_SUPPORT #ifdef MAKE_ZIM_SUPPORT
#define BUFSIZE 0xFFFF
string decompressLzma2( const char * bufptr, unsigned length, string decompressLzma2( const char * bufptr, unsigned length,
bool raw_decoder ) bool raw_decoder )
{ {
string str; string str;
lzma_ret res; lzma_ret res;
char buf[BUFSIZE]; char buf[CHUNK_SIZE];
lzma_stream strm = LZMA_STREAM_INIT; lzma_stream strm = LZMA_STREAM_INIT;
strm.next_in = reinterpret_cast< const uint8_t * >( bufptr ); strm.next_in = reinterpret_cast< const uint8_t * >( bufptr );
@ -118,9 +116,9 @@ char buf[BUFSIZE];
while ( res != LZMA_STREAM_END ) while ( res != LZMA_STREAM_END )
{ {
strm.next_out = reinterpret_cast< uint8_t * >( buf ); strm.next_out = reinterpret_cast< uint8_t * >( buf );
strm.avail_out = BUFSIZE; strm.avail_out = CHUNK_SIZE;
res = lzma_code( &strm, LZMA_RUN ); res = lzma_code( &strm, LZMA_RUN );
str.append( buf, BUFSIZE - strm.avail_out ); str.append( buf, CHUNK_SIZE - strm.avail_out );
if( res != LZMA_OK && res != LZMA_STREAM_END ) if( res != LZMA_OK && res != LZMA_STREAM_END )
break; break;
} }