public int Unwrap(ReadOnlySpan <byte> src, Span <byte> dst, bool bufferSizePrecheck = true) { if (bufferSizePrecheck) { var expectedDstSize = GetDecompressedSize(src); if (expectedDstSize > (ulong)dst.Length) { throw new ZstdException(ZSTD_ErrorCode.ZSTD_error_dstSize_tooSmall, "Destination buffer size is less than specified decompressed content size"); } } var dstSize = Options.Ddict == IntPtr.Zero ? ExternMethods.ZSTD_decompressDCtx(dctx, dst, (size_t)dst.Length, src, (size_t)src.Length) : ExternMethods.ZSTD_decompress_usingDDict(dctx, dst, (size_t)dst.Length, src, (size_t)src.Length, Options.Ddict); return((int)dstSize.EnsureZstdSuccess()); }
public int Unwrap(ArraySegment <byte> src, byte[] dst, int offset, bool bufferSizePrecheck = true) { if (offset < 0 || offset >= dst.Length) { throw new ArgumentOutOfRangeException(nameof(offset)); } if (src.Count == 0) { return(0); } var dstCapacity = dst.Length - offset; using (var srcPtr = new ArraySegmentPtr(src)) { if (bufferSizePrecheck) { var expectedDstSize = ExternMethods.ZSTD_getDecompressedSize(srcPtr, (size_t)src.Count); if ((int)expectedDstSize > dstCapacity) { throw new InsufficientMemoryException("Buffer size is less than specified decompressed data size"); } } size_t dstSize; using (var dstPtr = new ArraySegmentPtr(new ArraySegment <byte>(dst, offset, dstCapacity))) { if (Options.Ddict == IntPtr.Zero) { dstSize = ExternMethods.ZSTD_decompressDCtx(dctx, dstPtr, (size_t)dstCapacity, srcPtr, (size_t)src.Count); } else { dstSize = ExternMethods.ZSTD_decompress_usingDDict(dctx, dstPtr, (size_t)dstCapacity, srcPtr, (size_t)src.Count, Options.Ddict); } } dstSize.EnsureZstdSuccess(); return((int)dstSize); } }
// Token: 0x06000022 RID: 34 RVA: 0x000025C4 File Offset: 0x000007C4 public int Unwrap(ArraySegment <byte> src, byte[] dst, int offset, bool bufferSizePrecheck = true) { if (offset < 0 || offset >= dst.Length) { throw new ArgumentOutOfRangeException("offset"); } if (src.Count == 0) { return(0); } int num = dst.Length - offset; int result; using (ArraySegmentPtr arraySegmentPtr = new ArraySegmentPtr(src)) { if (bufferSizePrecheck && (int)ExternMethods.ZSTD_getDecompressedSize(arraySegmentPtr, (UIntPtr)((ulong)((long)src.Count))) > num) { throw new InsufficientMemoryException("Buffer size is less than specified decompressed data size"); } UIntPtr uintPtr; using (ArraySegmentPtr arraySegmentPtr2 = new ArraySegmentPtr(new ArraySegment <byte>(dst, offset, num))) { if (this.Options.Ddict == IntPtr.Zero) { uintPtr = ExternMethods.ZSTD_decompressDCtx(this.dctx, arraySegmentPtr2, (UIntPtr)((ulong)((long)num)), arraySegmentPtr, (UIntPtr)((ulong)((long)src.Count))); } else { uintPtr = ExternMethods.ZSTD_decompress_usingDDict(this.dctx, arraySegmentPtr2, (UIntPtr)((ulong)((long)num)), arraySegmentPtr, (UIntPtr)((ulong)((long)src.Count)), this.Options.Ddict); } } uintPtr.EnsureZstdSuccess(); result = (int)((uint)uintPtr); } return(result); }