]> git.ipfire.org Git - thirdparty/zstd.git/commitdiff
fixed fullbench freshCCtx scenario
authorYann Collet <cyan@fb.com>
Sun, 2 Jan 2022 07:46:49 +0000 (23:46 -0800)
committerYann Collet <cyan@fb.com>
Sun, 2 Jan 2022 07:46:49 +0000 (23:46 -0800)
tests/fullbench.c

index f610fef4c75d34d1b0c395fec8e8e2eb21745057..31b3b6da159da7ccfd3aec93910a457c73c1860d 100644 (file)
@@ -230,14 +230,15 @@ local_ZSTD_compressStream_freshCCtx(const void* src, size_t srcSize,
                           void* dst, size_t dstCapacity,
                           void* payload)
 {
-    ZSTD_CCtx* const cctx = ZSTD_createCCtx();
-    size_t r;
-    assert(cctx != NULL);
-
-    r = local_ZSTD_compressStream(src, srcSize, dst, dstCapacity, payload);
-
-    ZSTD_freeCCtx(cctx);
-    return r;
+    if (g_cstream != NULL) ZSTD_freeCCtx(g_cstream);
+    g_cstream = ZSTD_createCCtx();
+    assert(g_cstream != NULL);
+
+    {   size_t const r = local_ZSTD_compressStream(src, srcSize, dst, dstCapacity, payload);
+        ZSTD_freeCCtx(g_cstream);
+        g_cstream = NULL;
+        return r;
+    }
 }
 
 static size_t