p->streamEndWasReached = 1;\r
return;\r
}\r
- \r
+\r
for (;;)\r
{\r
Byte *dest = p->buffer + (p->streamPos - p->pos);\r
ISzAllocPtr alloc)\r
{\r
UInt32 sizeReserv;\r
- \r
+\r
if (historySize > kMaxHistorySize)\r
{\r
MatchFinder_Free(p, alloc);\r
return 0;\r
}\r
- \r
+\r
sizeReserv = historySize >> 1;\r
if (historySize >= ((UInt32)3 << 30)) sizeReserv = historySize >> 3;\r
else if (historySize >= ((UInt32)2 << 30)) sizeReserv = historySize >> 2;\r
- \r
+\r
sizeReserv += (keepAddBufferBefore + matchMaxLen + keepAddBufferAfter) / 2 + (1 << 19);\r
\r
p->keepSizeBefore = historySize + keepAddBufferBefore + 1;\r
p->keepSizeAfter = matchMaxLen + keepAddBufferAfter;\r
- \r
+\r
/* we need one additional byte, since we use MoveBlock after pos++ and before dictionary using */\r
- \r
+\r
if (LzInWindow_Create(p, sizeReserv, alloc))\r
{\r
UInt32 newCyclicBufferSize = historySize + 1;\r
p->historySize = historySize;\r
p->hashSizeSum = hs;\r
p->cyclicBufferSize = newCyclicBufferSize;\r
- \r
+\r
numSons = newCyclicBufferSize;\r
if (p->btMode)\r
numSons <<= 1;\r
\r
if (p->hash && p->numRefs == newSize)\r
return 1;\r
- \r
+\r
MatchFinder_FreeThisClassMemory(p, alloc);\r
p->numRefs = newSize;\r
p->hash = AllocRefs(newSize, alloc);\r
- \r
+\r
if (p->hash)\r
{\r
p->son = p->hash + p->hashSizeSum;\r
{\r
UInt32 limit = kMaxValForNormalize - p->pos;\r
UInt32 limit2 = p->cyclicBufferSize - p->cyclicBufferPos;\r
- \r
+\r
if (limit2 < limit)\r
limit = limit2;\r
limit2 = p->streamPos - p->pos;\r
- \r
+\r
if (limit2 <= p->keepSizeAfter)\r
{\r
if (limit2 > 0)\r
}\r
else\r
limit2 -= p->keepSizeAfter;\r
- \r
+\r
if (limit2 < limit)\r
limit = limit2;\r
- \r
+\r
{\r
UInt32 lenLimit = p->streamPos - p->pos;\r
if (lenLimit > p->matchMaxLen)\r
p->streamPos = p->cyclicBufferSize;\r
p->result = SZ_OK;\r
p->streamEndWasReached = 0;\r
- \r
+\r
if (readData)\r
MatchFinder_ReadBlock(p);\r
- \r
+\r
MatchFinder_SetLimits(p);\r
}\r
\r
MatchFinder_Init_3(p, True);\r
}\r
\r
- \r
+\r
static UInt32 MatchFinder_GetSubValue(CMatchFinder *p)\r
{\r
return (p->pos - p->historySize - 1) & kNormalizeMask;\r
d2 = pos - hash[h2];\r
\r
curMatch = (hash + kFix3HashSize)[hv];\r
- \r
+\r
hash[h2] = pos;\r
(hash + kFix3HashSize)[hv] = pos;\r
\r
MOVE_POS_RET;\r
}\r
}\r
- \r
+\r
GET_MATCHES_FOOTER(offset, maxLen)\r
}\r
\r
\r
maxLen = 0;\r
offset = 0;\r
- \r
+\r
if (d2 < p->cyclicBufferSize && *(cur - d2) == *cur)\r
{\r
distances[0] = maxLen = 2;\r
distances[1] = d2 - 1;\r
offset = 2;\r
}\r
- \r
+\r
if (d2 != d3 && d3 < p->cyclicBufferSize && *(cur - d3) == *cur)\r
{\r
maxLen = 3;\r
offset += 2;\r
d2 = d3;\r
}\r
- \r
+\r
if (offset != 0)\r
{\r
UPDATE_maxLen\r
MOVE_POS_RET;\r
}\r
}\r
- \r
+\r
if (maxLen < 3)\r
maxLen = 3;\r
- \r
+\r
GET_MATCHES_FOOTER(offset, maxLen)\r
}\r
\r
offset = 2;\r
d2 = d3;\r
}\r
- \r
+\r
if (d2 != d4 && d4 < p->cyclicBufferSize\r
&& *(cur - d4) == *cur\r
&& *(cur - d4 + 3) == *(cur + 3))\r
offset += 2;\r
d2 = d4;\r
}\r
- \r
+\r
if (offset != 0)\r
{\r
UPDATE_maxLen\r
\r
if (maxLen < 4)\r
maxLen = 4;\r
- \r
+\r
GET_MATCHES_FOOTER(offset, maxLen)\r
}\r
*/\r
\r
hash = p->hash;\r
pos = p->pos;\r
- \r
+\r
d2 = pos - hash[ h2];\r
d3 = pos - (hash + kFix3HashSize)[h3];\r
- \r
+\r
curMatch = (hash + kFix4HashSize)[hv];\r
\r
hash[ h2] = pos;\r
distances[1] = d2 - 1;\r
offset = 2;\r
}\r
- \r
+\r
if (d2 != d3 && d3 < p->cyclicBufferSize && *(cur - d3) == *cur)\r
{\r
maxLen = 3;\r
offset += 2;\r
d2 = d3;\r
}\r
- \r
+\r
if (offset != 0)\r
{\r
UPDATE_maxLen\r
MOVE_POS_RET;\r
}\r
}\r
- \r
+\r
if (maxLen < 3)\r
maxLen = 3;\r
\r
\r
hash = p->hash;\r
pos = p->pos;\r
- \r
+\r
d2 = pos - hash[ h2];\r
d3 = pos - (hash + kFix3HashSize)[h3];\r
d4 = pos - (hash + kFix4HashSize)[h4];\r
offset = 2;\r
d2 = d3;\r
}\r
- \r
+\r
if (d2 != d4 && d4 < p->cyclicBufferSize\r
&& *(cur - d4) == *cur\r
&& *(cur - d4 + 3) == *(cur + 3))\r
offset += 2;\r
d2 = d4;\r
}\r
- \r
+\r
if (offset != 0)\r
{\r
UPDATE_maxLen\r
MOVE_POS_RET;\r
}\r
}\r
- \r
+\r
if (maxLen < 4)\r
maxLen = 4;\r
\r