private SRes LzmaEnc_Alloc(uint keepWindowSize, ISzAlloc alloc, ISzAlloc allocBig) { if (!mRC.RangeEnc_Alloc(alloc)) return SZ_ERROR_MEM; bool btMode = mMatchFinderBase.mBtMode; #if !_7ZIP_ST mMtMode = (mMultiThread && !mFastMode && btMode); #endif int lclp = mLC + mLP; if (mLitProbs == null || mSaveState.mLitProbs == null || mLcLp != lclp) { LzmaEnc_FreeLits(alloc); mLitProbs = alloc.AllocUInt16(alloc, 0x300 << lclp); mSaveState.mLitProbs = alloc.AllocUInt16(alloc, 0x300 << lclp); if (mLitProbs == null || mSaveState.mLitProbs == null) { LzmaEnc_FreeLits(alloc); return SZ_ERROR_MEM; } mLcLp = lclp; } mMatchFinderBase.mBigHash = (mDictSize > kBigHashDicLimit); uint beforeSize = kNumOpts; if (beforeSize + mDictSize < keepWindowSize) beforeSize = keepWindowSize - mDictSize; #if !_7ZIP_ST if (mMtMode) { SRes res; if ((res = mMatchFinderMt.MatchFinderMt_Create(mDictSize, beforeSize, mNumFastBytes, LZMA_MATCH_LEN_MAX, allocBig)) != SZ_OK) return res; mMatchFinderObj = mMatchFinderMt; mMatchFinderMt.MatchFinderMt_CreateVTable(out mMatchFinder); } else #endif { if (!mMatchFinderBase.MatchFinder_Create(mDictSize, beforeSize, mNumFastBytes, LZMA_MATCH_LEN_MAX, allocBig)) return SZ_ERROR_MEM; mMatchFinderObj = mMatchFinderBase; MatchFinder_CreateVTable(mMatchFinderBase, out mMatchFinder); } return SZ_OK; }
private SRes LzmaDec_AllocateProbs2(CLzmaProps propNew, ISzAlloc alloc) { uint numProbs = LzmaProps_GetNumProbs(propNew); if (mProbs == null || numProbs != mNumProbs) { LzmaDec_FreeProbs(alloc); mProbs = alloc.AllocUInt16(alloc, numProbs); mNumProbs = numProbs; if (mProbs == null) return SZ_ERROR_MEM; } return SZ_OK; }