Ejemplo n.º 1
0
 public static void ZSTD_copyDDictParameters(ZSTD_DCtx_s *dctx, ZSTD_DDict_s *ddict)
 {
     assert(dctx != null);
     assert(ddict != null);
     dctx->dictID         = ddict->dictID;
     dctx->prefixStart    = ddict->dictContent;
     dctx->virtualStart   = ddict->dictContent;
     dctx->dictEnd        = (byte *)(ddict->dictContent) + ddict->dictSize;
     dctx->previousDstEnd = dctx->dictEnd;
     if (ddict->entropyPresent != 0)
     {
         dctx->litEntropy     = 1;
         dctx->fseEntropy     = 1;
         dctx->LLTptr         = ddict->entropy.LLTable;
         dctx->MLTptr         = ddict->entropy.MLTable;
         dctx->OFTptr         = ddict->entropy.OFTable;
         dctx->HUFptr         = ddict->entropy.hufTable;
         dctx->entropy.rep[0] = ddict->entropy.rep[0];
         dctx->entropy.rep[1] = ddict->entropy.rep[1];
         dctx->entropy.rep[2] = ddict->entropy.rep[2];
     }
     else
     {
         dctx->litEntropy = 0;
         dctx->fseEntropy = 0;
     }
 }
Ejemplo n.º 2
0
 private void ReleaseUnmanagedResources()
 {
     if (dctx != null)
     {
         Methods.ZSTD_freeDCtx(dctx);
         dctx = null;
     }
 }
Ejemplo n.º 3
0
 public Decompressor()
 {
     dctx = Methods.ZSTD_createDCtx();
     if (dctx == null)
     {
         throw new ZstdException(ZSTD_ErrorCode.ZSTD_error_GENERIC, "Failed to create dctx");
     }
 }
Ejemplo n.º 4
0
        public void Setup()
        {
            cCtx = Methods.ZSTD_createCCtx();
            dCtx = Methods.ZSTD_createDCtx();

            cCtxNative = ExternMethods.ZSTD_createCCtx();
            dCtxNative = ExternMethods.ZSTD_createDCtx();

            src          = File.ReadAllBytes("dickens");
            dest         = new byte[Methods.ZSTD_compressBound((nuint)src.Length)];
            uncompressed = new byte[src.Length];

            fixed(byte *dstPtr = dest)
            fixed(byte *srcPtr = src)
            {
                compressedLength = ExternMethods.ZSTD_compressCCtx(cCtxNative, (IntPtr)dstPtr, (nuint)dest.Length,
                                                                   (IntPtr)srcPtr, (nuint)src.Length,
                                                                   level);
            }
        }