diff options
Diffstat (limited to '7zip/Compress/LZ/LZInWindow.h')
-rwxr-xr-x | 7zip/Compress/LZ/LZInWindow.h | 25 |
1 files changed, 14 insertions, 11 deletions
diff --git a/7zip/Compress/LZ/LZInWindow.h b/7zip/Compress/LZ/LZInWindow.h index a9cb7320..54f2cb7b 100755 --- a/7zip/Compress/LZ/LZInWindow.h +++ b/7zip/Compress/LZ/LZInWindow.h @@ -9,7 +9,7 @@ class CLZInWindow { Byte *_bufferBase; // pointer to buffer with data ISequentialInStream *_stream; - UInt32 _posLimit; // offset (from _buffer) of first byte when new block reading must be done + UInt32 _posLimit; // offset (from _buffer) when new block reading must be done bool _streamEndWasReached; // if (true) then _streamPos shows real end of stream const Byte *_pointerToLastSafePosition; protected: @@ -18,22 +18,20 @@ protected: UInt32 _pos; // offset (from _buffer) of curent byte UInt32 _keepSizeBefore; // how many BYTEs must be kept in buffer before _pos UInt32 _keepSizeAfter; // how many BYTEs must be kept buffer after _pos - UInt32 _keepSizeReserv; // how many BYTEs must be kept as reserv UInt32 _streamPos; // offset (from _buffer) of first not read byte from Stream - virtual void BeforeMoveBlock() {}; - virtual void AfterMoveBlock() {}; void MoveBlock(); - virtual HRESULT ReadBlock(); + HRESULT ReadBlock(); void Free(); public: CLZInWindow(): _bufferBase(0) {} virtual ~CLZInWindow() { Free(); } - bool Create(UInt32 keepSizeBefore, UInt32 keepSizeAfter, - UInt32 keepSizeReserv = (1<<17)); + // keepSizeBefore + keepSizeAfter + keepSizeReserv < 4G) + bool Create(UInt32 keepSizeBefore, UInt32 keepSizeAfter, UInt32 keepSizeReserv = (1<<17)); - HRESULT Init(ISequentialInStream *stream); + void SetStream(ISequentialInStream *stream); + HRESULT Init(); // void ReleaseStream(); Byte *GetBuffer() const { return _buffer; } @@ -53,17 +51,17 @@ public: else return S_OK; } - Byte GetIndexByte(Int32 index)const - { return _buffer[(size_t)_pos + index]; } + Byte GetIndexByte(Int32 index) const { return _buffer[(size_t)_pos + index]; } // index + limit have not to exceed _keepSizeAfter; + // -2G <= index < 2G UInt32 GetMatchLen(Int32 index, UInt32 distance, UInt32 limit) const { if(_streamEndWasReached) if ((_pos + index) + limit > _streamPos) limit = _streamPos - (_pos + index); distance++; - Byte *pby = _buffer + (size_t)_pos + index; + const Byte *pby = _buffer + (size_t)_pos + index; UInt32 i; for(i = 0; i < limit && pby[i] == pby[(size_t)i - distance]; i++); return i; @@ -79,6 +77,11 @@ public: _streamPos -= subValue; } + bool NeedMove(UInt32 numCheckBytes) + { + UInt32 reserv = _pointerToLastSafePosition - (_buffer + _pos); + return (reserv <= numCheckBytes); + } }; #endif |