diff options
Diffstat (limited to '7zip/Compress/LZ/LZInWindow.cpp')
-rwxr-xr-x | 7zip/Compress/LZ/LZInWindow.cpp | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/7zip/Compress/LZ/LZInWindow.cpp b/7zip/Compress/LZ/LZInWindow.cpp index 64928806..0e65c425 100755 --- a/7zip/Compress/LZ/LZInWindow.cpp +++ b/7zip/Compress/LZ/LZInWindow.cpp @@ -16,7 +16,6 @@ bool CLZInWindow::Create(UInt32 keepSizeBefore, UInt32 keepSizeAfter, UInt32 kee { _keepSizeBefore = keepSizeBefore; _keepSizeAfter = keepSizeAfter; - _keepSizeReserv = keepSizeReserv; UInt32 blockSize = keepSizeBefore + keepSizeAfter + keepSizeReserv; if (_bufferBase == 0 || _blockSize != blockSize) { @@ -31,10 +30,13 @@ bool CLZInWindow::Create(UInt32 keepSizeBefore, UInt32 keepSizeAfter, UInt32 kee return (_bufferBase != 0); } - -HRESULT CLZInWindow::Init(ISequentialInStream *stream) +void CLZInWindow::SetStream(ISequentialInStream *stream) { _stream = stream; +} + +HRESULT CLZInWindow::Init() +{ _buffer = _bufferBase; _pos = 0; _streamPos = 0; @@ -68,7 +70,7 @@ HRESULT CLZInWindow::ReadBlock() return S_OK; while(true) { - UInt32 size = UInt32(_bufferBase - _buffer) + _blockSize - _streamPos; + UInt32 size = (UInt32)(_bufferBase - _buffer) + _blockSize - _streamPos; if(size == 0) return S_OK; UInt32 numReadBytes; @@ -93,10 +95,11 @@ HRESULT CLZInWindow::ReadBlock() void CLZInWindow::MoveBlock() { - BeforeMoveBlock(); - UInt32 offset = UInt32(_buffer - _bufferBase) + _pos - _keepSizeBefore; - UInt32 numBytes = UInt32(_buffer - _bufferBase) + _streamPos - offset; + UInt32 offset = (UInt32)(_buffer - _bufferBase) + _pos - _keepSizeBefore; + // we need one additional byte, since MovePos moves on 1 byte. + if (offset > 0) + offset--; + UInt32 numBytes = (UInt32)(_buffer - _bufferBase) + _streamPos - offset; memmove(_bufferBase, _bufferBase + offset, numBytes); _buffer -= offset; - AfterMoveBlock(); } |