]> git.ipfire.org Git - thirdparty/zstd.git/commitdiff
fixed streaming_memory_usage example
authorYann Collet <cyan@fb.com>
Thu, 8 Feb 2018 07:13:19 +0000 (23:13 -0800)
committerYann Collet <cyan@fb.com>
Thu, 8 Feb 2018 07:42:09 +0000 (23:42 -0800)
also:
ensure zstd.h is read from ../lib (instead of /usr/include)

examples/Makefile
examples/streaming_memory_usage.c

index 52470f59933eb00533e18ce95ff9a1fe94ce182e..2910d23b6c7fd0125448dec0a35854b24eea79a1 100644 (file)
@@ -9,6 +9,7 @@
 
 # This Makefile presumes libzstd is installed, using `sudo make install`
 
+CPPFLAGS += -I../lib
 LIB = ../lib/libzstd.a
 
 .PHONY: default all clean test
index b056c2a59ee4c48e3da9ee033f2fb614afac5526..5e7e13e824eacdee161337e45a257a1da7df215d 100644 (file)
@@ -46,7 +46,7 @@ static unsigned readU32FromChar(const char** stringPtr)
 
 int main(int argc, char const *argv[]) {
 
-    printf("\n Zstandard (v%u) memory usage for streaming contexts : \n\n", ZSTD_versionNumber());
+    printf("\n Zstandard (v%s) memory usage for streaming : \n\n", ZSTD_versionString());
 
     unsigned wLog = 0;
     if (argc > 1) {
@@ -69,11 +69,13 @@ int main(int argc, char const *argv[]) {
 
         /* forces compressor to use maximum memory size for given compression level,
          * by not providing any information on input size */
-        ZSTD_parameters params = ZSTD_getParams(compressionLevel, 0, 0);
+        ZSTD_parameters params = ZSTD_getParams(compressionLevel, ZSTD_CONTENTSIZE_UNKNOWN, 0);
         if (wLog) { /* special mode : specific wLog */
             printf("Using custom compression parameter : level 1 + wLog=%u \n", wLog);
-            params = ZSTD_getParams(1, 1 << wLog, 0);
-            size_t const error = ZSTD_initCStream_advanced(cstream, NULL, 0, params, 0);
+            params = ZSTD_getParams(1 /*compressionLevel*/,
+                                    1 << wLog /*estimatedSrcSize*/,
+                                    0 /*no dictionary*/);
+            size_t const error = ZSTD_initCStream_advanced(cstream, NULL, 0, params, ZSTD_CONTENTSIZE_UNKNOWN);
             if (ZSTD_isError(error)) {
                 printf("ZSTD_initCStream_advanced error : %s \n", ZSTD_getErrorName(error));
                 return 1;