]> git.ipfire.org Git - thirdparty/zstd.git/commitdiff
tests with ZSTD_setPledgedSrcSize
authorinikep <inikep@gmail.com>
Wed, 21 Sep 2016 15:17:29 +0000 (17:17 +0200)
committerinikep <inikep@gmail.com>
Wed, 21 Sep 2016 15:17:29 +0000 (17:17 +0200)
zlibWrapper/examples/fitblk.c
zlibWrapper/zstd_zlibwrapper.c
zlibWrapper/zstd_zlibwrapper.h

index 12e4c862641c9caa83632c43741d73ccc35b992e..2666b2456747f4209ed60695618cef9da2309fc6 100644 (file)
@@ -162,13 +162,19 @@ int main(int argc, char **argv)
     ret = deflateInit(&def, Z_DEFAULT_COMPRESSION);
     if (ret != Z_OK || blk == NULL)
         quit("out of memory");
+    ret = ZSTD_setPledgedSrcSize(&def, 1<<16);
+    if (ret != Z_OK)
+        quit("ZSTD_setPledgedSrcSize");
+    ret = deflateReset(&def);
+    if (ret != Z_OK)
+        quit("deflateReset");
 
     /* compress from stdin until output full, or no more input */
     def.avail_out = size + EXCESS;
     def.next_out = blk;
     LOG_FITBLK("partcompress1 total_in=%d total_out=%d\n", (int)def.total_in, (int)def.total_out);
     ret = partcompress(stdin, &def);
-    LOG_FITBLK("partcompress2 total_in=%d total_out=%d\n", (int)def.total_in, (int)def.total_out);
+    printf("partcompress total_in=%d total_out=%d\n", (int)def.total_in, (int)def.total_out);
     if (ret == Z_ERRNO)
         quit("error reading input");
 
index 0c09e6fb907c95173080d62a1b076db09bcaa4c4..d921f54768447e3e98ef2d5c20bcaf1cbca010c5 100644 (file)
@@ -112,7 +112,7 @@ ZWRAP_CCtx* ZWRAP_createCCtx(z_streamp strm)
         memcpy(&zwc->customMem, &defaultCustomMem, sizeof(ZSTD_customMem));
     }
 
-    zwc->pledgedSrcSize = 1<<16;
+    zwc->pledgedSrcSize = 0;
     zwc->zbc = ZSTD_createCStream_advanced(zwc->customMem);
     if (zwc->zbc == NULL) { ZWRAP_freeCCtx(zwc); return NULL; }
     return zwc;
index f7763b2f0a273d054dc80badfbc78437f907bec4..149d5ace5b3492a18fa1365358a9dc9c90c2e35d 100644 (file)
@@ -35,7 +35,7 @@ int isUsingZSTD(void);
 /* returns a string with version of zstd library */
 const char * zstdVersion(void);
 
-/* Changes a pledged source size for a given stream.
+/* Changes a pledged source size for a given compression stream.
    The function should be called after deflateInit().
    After this function deflateReset() should be called. */
 int ZSTD_setPledgedSrcSize(z_streamp strm, unsigned long long pledgedSrcSize);