#if !Rar2017_64bit using nint = System.Int32; using nuint = System.UInt32; using size_t = System.UInt32; #else using nint = System.Int64; using nuint = System.UInt64; using size_t = System.UInt64; #endif using int64 = System.Int64; using System; namespace SharpCompress.Compressors.Rar.UnpackV2017 { internal partial class FragmentedWindow { public FragmentedWindow() { //memset(Mem,0,sizeof(Mem)); //memset(MemSize,0,sizeof(MemSize)); } //FragmentedWindow::~FragmentedWindow() //{ // Reset(); //} private void Reset() { for (uint I=0;I=MinSize) { NewMem=new byte[Size]; if (NewMem!=null) break; Size-=Size/32; } if (NewMem==null) //throw std::bad_alloc(); throw new InvalidOperationException(); // Clean the window to generate the same output when unpacking corrupt // RAR files, which may access to unused areas of sliding dictionary. // sharpcompress: don't need this, freshly allocated above //Utility.Memset(NewMem,0,Size); Mem[BlockNum]=NewMem; TotalSize+=Size; MemSize[BlockNum]=TotalSize; BlockNum++; } if (TotalSize 0) { this[UnpPtr]=this[SrcPtr++ & MaxWinMask]; // We need to have masked UnpPtr after quit from loop, so it must not // be replaced with '(*this)[UnpPtr++ & MaxWinMask]' UnpPtr=(UnpPtr+1) & MaxWinMask; } } public void CopyData(byte[] Dest, size_t destOffset, size_t WinPos,size_t Size) { for (size_t I=0;I