Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- enum {
- kMaxValForNormalize=0xFFFFFFFF,
- kNormalizeStepMin = 1<<10, // it must be power of 2
- kNormalizeMask = ~(kNormalizeStepMin-1)
- };
- void MatchFinder_CheckLimits( uint flag=0 ) {
- // reached 4G?
- if( pos==kMaxValForNormalize ) {
- uint subValue = (pos - historySize - 1) & kNormalizeMask;
- uint i;
- uint* items = hash;
- uint numItems = hashSizeSum + numSons;
- for( i=0; i<numItems; i++ ) {
- uint value = items[i];
- value = (value<=subValue) ? kEmptyHashValue : value-subValue;
- items[i] = value;
- }
- posLimit -= subValue;
- pos -= subValue;
- streamPos -= subValue;
- }
- if( flag || ((!streamEndWasReached) && (pos+keepSizeAfter==streamPos)) ) {
- if( buffer+keepSizeAfter>=bufferBase+blockSize ) {
- memmove( bufferBase, buffer - keepSizeBefore, streamPos+keepSizeBefore - pos );
- buffer = bufferBase + keepSizeBefore;
- }
- if( streamEndWasReached==0 ) {
- byte* dest = buffer + (streamPos-pos);
- uint size = bufferBase + blockSize - dest;
- if( size>0 ) {
- // here "size" is what we can read max
- chkinp(); // yield if no input
- if( f_quit ) size=0; else {
- uint inplen = getinplen(); // coro has this much input
- size = Min(size,inplen);
- memcpy( dest, (byte*)inpptr, size ); // fetch what we have of input
- inpptr += size; // normally would pointer to inpend now
- }
- if( size==0 ) streamEndWasReached=1;
- streamPos += size;
- }
- }
- }
- if( cyclicBufferPos==cyclicBufferSize ) cyclicBufferPos=0;
- lenLimit = Min<uint>( matchMaxLen, streamPos - pos );
- uint limit = kMaxValForNormalize - pos; // bytes until 4G
- uint limit2 = cyclicBufferSize - cyclicBufferPos; // bytes until end of tree buf
- if( limit2<limit ) limit=limit2;
- limit2 = streamPos - pos; // bytes until end of stream-keepSizeAfter
- if( limit2<=keepSizeAfter ) {
- if( limit2>0 ) limit2=1;
- } else {
- limit2 -= keepSizeAfter;
- }
- if( limit2<limit ) limit = limit2;
- posLimit = pos + limit;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement