]> git.ipfire.org Git - thirdparty/zstd.git/commitdiff
streaming example uses stable API
authorYann Collet <cyan@fb.com>
Fri, 9 Dec 2016 01:28:26 +0000 (17:28 -0800)
committerYann Collet <cyan@fb.com>
Fri, 9 Dec 2016 01:28:26 +0000 (17:28 -0800)
examples/streaming_compression.c

index 108a63c8365c858f51ea12181f7786a3d373ef0e..4c2c1a1d8bc727ac0e045928cd75005f9f694f66 100644 (file)
@@ -7,11 +7,9 @@
  */
 
 
-#include <stdlib.h>    // malloc, exit
-#include <stdio.h>     // fprintf, perror, feof
-#include <string.h>    // strerror
-#include <errno.h>     // errno
-#define ZSTD_STATIC_LINKING_ONLY  // streaming API defined as "experimental" for the time being
+#include <stdlib.h>    // malloc, free, exit
+#include <stdio.h>     // fprintf, perror, feof, fopen, etc.
+#include <string.h>    // strlen, memset, strcat
 #include <zstd.h>      // presumes zstd library is installed
 
 
@@ -82,7 +80,7 @@ static void compressFile_orDie(const char* fname, const char* outName, int cLeve
             ZSTD_outBuffer output = { buffOut, buffOutSize, 0 };
             toRead = ZSTD_compressStream(cstream, &output , &input);   /* toRead is guaranteed to be <= ZSTD_CStreamInSize() */
             if (ZSTD_isError(toRead)) { fprintf(stderr, "ZSTD_compressStream() error : %s \n", ZSTD_getErrorName(toRead)); exit(12); }
-            if (toRead > buffInSize) toRead = buffInSize;   /* Safely handle when `buffInSize` is manually changed to a smaller value */
+            if (toRead > buffInSize) toRead = buffInSize;   /* Safely handle case when `buffInSize` is manually changed to a value < ZSTD_CStreamInSize()*/
             fwrite_orDie(buffOut, output.pos, fout);
         }
     }