// Token: 0x06000020 RID: 32 RVA: 0x00002564 File Offset: 0x00000764 public static ulong GetDecompressedSize(ArraySegment <byte> src) { ulong result; using (ArraySegmentPtr arraySegmentPtr = new ArraySegmentPtr(src)) { result = ExternMethods.ZSTD_getDecompressedSize(arraySegmentPtr, (UIntPtr)((ulong)((long)src.Count))); } return(result); }
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); }
public static ulong GetDecompressedSize(ArraySegment <byte> src) { using (var srcPtr = new ArraySegmentPtr(src)) return(ExternMethods.ZSTD_getDecompressedSize(srcPtr, (size_t)src.Count)); }