Beispiel #1
0
        // Token: 0x06000013 RID: 19 RVA: 0x00002270 File Offset: 0x00000470
        public int Wrap(ArraySegment <byte> src, byte[] dst, int offset)
        {
            if (offset < 0 || offset >= dst.Length)
            {
                throw new ArgumentOutOfRangeException("offset");
            }
            if (src.Count == 0)
            {
                return(0);
            }
            int     num = dst.Length - offset;
            UIntPtr uintPtr;

            using (ArraySegmentPtr arraySegmentPtr = new ArraySegmentPtr(src))
            {
                using (ArraySegmentPtr arraySegmentPtr2 = new ArraySegmentPtr(new ArraySegment <byte>(dst, offset, num)))
                {
                    if (this.Options.Cdict == IntPtr.Zero)
                    {
                        uintPtr = ExternMethods.ZSTD_compressCCtx(this.cctx, arraySegmentPtr2, (UIntPtr)((ulong)((long)num)), arraySegmentPtr, (UIntPtr)((ulong)((long)src.Count)), this.Options.CompressionLevel);
                    }
                    else
                    {
                        uintPtr = ExternMethods.ZSTD_compress_usingCDict(this.cctx, arraySegmentPtr2, (UIntPtr)((ulong)((long)num)), arraySegmentPtr, (UIntPtr)((ulong)((long)src.Count)), this.Options.Cdict);
                    }
                }
            }
            uintPtr.EnsureZstdSuccess();
            return((int)((uint)uintPtr));
        }
Beispiel #2
0
        public int Wrap(ArraySegment <byte> src, byte[] dst, int offset)
        {
            if (offset < 0 || offset >= dst.Length)
            {
                throw new ArgumentOutOfRangeException("offset");
            }

            if (src.Count == 0)
            {
                return(0);
            }

            var    dstCapacity = dst.Length - offset;
            size_t dstSize;

            using (var srcPtr = new ArraySegmentPtr(src))
                using (var dstPtr = new ArraySegmentPtr(new ArraySegment <byte>(dst, offset, dstCapacity)))
                {
                    if (Options.Cdict == IntPtr.Zero)
                    {
                        dstSize = ExternMethods.ZSTD_compressCCtx(cctx, dstPtr, (size_t)dstCapacity, srcPtr, (size_t)src.Count, Options.CompressionLevel);
                    }
                    else
                    {
                        dstSize = ExternMethods.ZSTD_compress_usingCDict(cctx, dstPtr, (size_t)dstCapacity, srcPtr, (size_t)src.Count, Options.Cdict);
                    }
                }
            dstSize.EnsureZstdSuccess();
            return((int)dstSize);
        }
Beispiel #3
0
        public int Wrap(ReadOnlySpan <byte> src, Span <byte> dst)
        {
            var dstSize = Options.AdvancedParams != null
                                ? ExternMethods.ZSTD_compress2(cctx, dst, (size_t)dst.Length, src, (size_t)src.Length)
                                : Options.Cdict == IntPtr.Zero
                                        ? ExternMethods.ZSTD_compressCCtx(cctx, dst, (size_t)dst.Length, src, (size_t)src.Length, Options.CompressionLevel)
                                        : ExternMethods.ZSTD_compress_usingCDict(cctx, dst, (size_t)dst.Length, src, (size_t)src.Length, Options.Cdict);

            return((int)dstSize.EnsureZstdSuccess());
        }