private static void ZSTD_window_enforceMaxDist(ZSTD_window_t *window, void *blockEnd, uint maxDist, uint *loadedDictEndPtr, ZSTD_matchState_t **dictMatchStatePtr) { uint blockEndIdx = (uint)((byte *)(blockEnd) - window->@base); uint loadedDictEnd = (loadedDictEndPtr != null) ? *loadedDictEndPtr : 0; if (blockEndIdx > maxDist + loadedDictEnd) { uint newLowLimit = blockEndIdx - maxDist; if (window->lowLimit < newLowLimit) { window->lowLimit = newLowLimit; } if (window->dictLimit < window->lowLimit) { window->dictLimit = window->lowLimit; } if (loadedDictEndPtr != null) { *loadedDictEndPtr = 0; } if (dictMatchStatePtr != null) { *dictMatchStatePtr = null; } } }
private static void ZSTD_window_clear(ZSTD_window_t *window) { nuint endT = (nuint)(window->nextSrc - window->@base); uint end = (uint)(endT); window->lowLimit = end; window->dictLimit = end; }
private static void ZSTD_window_init(ZSTD_window_t *window) { memset((void *)(window), (0), ((nuint)(sizeof(ZSTD_window_t)))); window->@base = (byte *)(GetStringPointer("")); window->dictBase = (byte *)(GetStringPointer("")); window->dictLimit = 1; window->lowLimit = 1; window->nextSrc = window->@base + 1; }
private static uint ZSTD_window_update(ZSTD_window_t *window, void *src, nuint srcSize) { byte *ip = (byte *)(src); uint contiguous = 1; if (srcSize == 0) { return(contiguous); } assert(window->@base != null); assert(window->dictBase != null); if (src != window->nextSrc) { nuint distanceFromBase = (nuint)(window->nextSrc - window->@base); window->lowLimit = window->dictLimit; assert(distanceFromBase == (nuint)((uint)(distanceFromBase))); window->dictLimit = (uint)(distanceFromBase); window->dictBase = window->@base; window->@base = ip - distanceFromBase; if (window->dictLimit - window->lowLimit < 8) { window->lowLimit = window->dictLimit; } contiguous = 0; } window->nextSrc = ip + srcSize; if (((ip + srcSize > window->dictBase + window->lowLimit) && (ip < window->dictBase + window->dictLimit))) { nint highInputIdx = (nint)((ip + srcSize) - window->dictBase); uint lowLimitMax = (highInputIdx > (nint)(window->dictLimit)) ? window->dictLimit : (uint)(highInputIdx); window->lowLimit = lowLimitMax; } return(contiguous); }
private static uint ZSTD_window_correctOverflow(ZSTD_window_t *window, uint cycleLog, uint maxDist, void *src) { uint cycleMask = (1U << (int)cycleLog) - 1; uint curr = (uint)((byte *)(src) - window->@base); uint currentCycle0 = curr & cycleMask; uint currentCycle1 = currentCycle0 == 0 ? (1U << (int)cycleLog) : currentCycle0; uint newCurrent = currentCycle1 + maxDist; uint correction = curr - newCurrent; assert((maxDist & cycleMask) == 0); assert(curr > newCurrent); assert(correction > (uint)(1 << 28)); window->@base += correction; window->dictBase += correction; if (window->lowLimit <= correction) { window->lowLimit = 1; } else { window->lowLimit -= correction; } if (window->dictLimit <= correction) { window->dictLimit = 1; } else { window->dictLimit -= correction; } assert(newCurrent >= maxDist); assert(newCurrent - maxDist >= 1); assert(window->lowLimit <= newCurrent); assert(window->dictLimit <= newCurrent); return(correction); }
private static void ZSTD_checkDictValidity(ZSTD_window_t *window, void *blockEnd, uint maxDist, uint *loadedDictEndPtr, ZSTD_matchState_t **dictMatchStatePtr) { assert(loadedDictEndPtr != null); assert(dictMatchStatePtr != null); { uint blockEndIdx = (uint)((byte *)(blockEnd) - window->@base); uint loadedDictEnd = *loadedDictEndPtr; assert(blockEndIdx >= loadedDictEnd); if (blockEndIdx > loadedDictEnd + maxDist) { *loadedDictEndPtr = 0; *dictMatchStatePtr = null; } else { if (*loadedDictEndPtr != 0) { ; } } } }