]> git.proxmox.com Git - ceph.git/blobdiff - ceph/src/zstd/tests/roundTripCrash.c
import 15.2.0 Octopus source
[ceph.git] / ceph / src / zstd / tests / roundTripCrash.c
index 180fa9b6f6dcdc1459ea2605016414ca089ef93e..3de5933185d52281afc50211ca5172b412437131 100644 (file)
@@ -85,7 +85,7 @@ static size_t cctxParamRoundTripTest(void* resultBuff, size_t resultBuffCapacity
     ZSTD_CCtx* const cctx = ZSTD_createCCtx();
     ZSTD_CCtx_params* const cctxParams = ZSTD_createCCtxParams();
     ZSTD_inBuffer inBuffer = { srcBuff, srcBuffSize, 0 };
-    ZSTD_outBuffer outBuffer = {compressedBuff, compressedBuffCapacity, 0 };
+    ZSTD_outBuffer outBuffer = { compressedBuff, compressedBuffCapacity, 0 };
 
     static const int maxClevel = 19;
     size_t const hashLength = MIN(128, srcBuffSize);
@@ -93,15 +93,15 @@ static size_t cctxParamRoundTripTest(void* resultBuff, size_t resultBuffCapacity
     int const cLevel = h32 % maxClevel;
 
     /* Set parameters */
-    CHECK_Z( ZSTD_CCtxParam_setParameter(cctxParams, ZSTD_p_compressionLevel, cLevel) );
-    CHECK_Z( ZSTD_CCtxParam_setParameter(cctxParams, ZSTD_p_nbThreads, 2) );
-    CHECK_Z( ZSTD_CCtxParam_setParameter(cctxParams, ZSTD_p_overlapSizeLog, 5) );
+    CHECK_Z( ZSTD_CCtxParams_setParameter(cctxParams, ZSTD_c_compressionLevel, cLevel) );
+    CHECK_Z( ZSTD_CCtxParams_setParameter(cctxParams, ZSTD_c_nbWorkers, 2) );
+    CHECK_Z( ZSTD_CCtxParams_setParameter(cctxParams, ZSTD_c_overlapLog, 5) );
 
 
     /* Apply parameters */
     CHECK_Z( ZSTD_CCtx_setParametersUsingCCtxParams(cctx, cctxParams) );
 
-    CHECK_Z (ZSTD_compress_generic(cctx, &outBuffer, &inBuffer, ZSTD_e_end) );
+    CHECK_Z (ZSTD_compressStream2(cctx, &outBuffer, &inBuffer, ZSTD_e_end) );
 
     ZSTD_freeCCtxParams(cctxParams);
     ZSTD_freeCCtx(cctx);
@@ -212,7 +212,7 @@ static void loadFile(void* buffer, const char* fileName, size_t fileSize)
 static void fileCheck(const char* fileName, int testCCtxParams)
 {
     size_t const fileSize = getFileSize(fileName);
-    void* buffer = malloc(fileSize);
+    void* const buffer = malloc(fileSize + !fileSize /* avoid 0 */);
     if (!buffer) {
         fprintf(stderr, "not enough memory \n");
         exit(4);