]> git.ipfire.org Git - thirdparty/zstd.git/commitdiff
added comment on ZSTD_COMPRESSBOUND() 877/head
authorYann Collet <cyan@fb.com>
Sun, 1 Oct 2017 18:32:38 +0000 (11:32 -0700)
committerYann Collet <cyan@fb.com>
Sun, 1 Oct 2017 18:32:38 +0000 (11:32 -0700)
as requested by @terrelln

lib/zstd.h

index 02491ed40154e4bbae15ba27dcf5dbdf57c80e94..4e225bb5ed8237a7ece4ab96f2c5ab81df237d58 100644 (file)
@@ -131,7 +131,7 @@ ZSTDLIB_API unsigned long long ZSTD_getDecompressedSize(const void* src, size_t
 
 
 /*======  Helper functions  ======*/
-#define ZSTD_COMPRESSBOUND(srcSize)   ((srcSize) + ((srcSize)>>8) + (((srcSize) < 128 KB) ? ((128 KB - (srcSize)) >> 11) /* margin, from 64 to 0 */ : 0))
+#define ZSTD_COMPRESSBOUND(srcSize)   ((srcSize) + ((srcSize)>>8) + (((srcSize) < 128 KB) ? ((128 KB - (srcSize)) >> 11) /* margin, from 64 to 0 */ : 0))  /* this formula ensures that bound(A) + bound(B) <= bound(A+B) as long as A and B >= 128 KB */
 ZSTDLIB_API size_t      ZSTD_compressBound(size_t srcSize); /*!< maximum compressed size in worst case scenario */
 ZSTDLIB_API unsigned    ZSTD_isError(size_t code);          /*!< tells if a `size_t` function result is an error code */
 ZSTDLIB_API const char* ZSTD_getErrorName(size_t code);     /*!< provides readable string from an error code */