From: Yann Collet Date: Tue, 19 Jul 2016 13:06:55 +0000 (+0200) Subject: minor comments clarifications X-Git-Tag: v0.8.0^2~71 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d5c5a779907bbd8295381b44af4166d227947882;p=thirdparty%2Fzstd.git minor comments clarifications --- diff --git a/NEWS b/NEWS index e3dd19102..50aadcbdb 100644 --- a/NEWS +++ b/NEWS @@ -1,11 +1,12 @@ v0.7.5 Fixed : premature end of frame when zero-sized raw block, reported by Eric Biggers +Fixed : legacy mode with ZSTD_HEAPMODE=0, by Christopher Bergqvist Modified : minor compression level adaptations Update : specification, to v0.1.2 : max huffman depth at 11 bits changed : zstd.h moved to /lib directory v0.7.4 -Added : homebrew for Mac +Added : homebrew for Mac, by Daniel Cade Added : more examples Fixed : segfault when using small dictionaries, reported by Felix Handte Modified : default compression level for CLI is now 3 diff --git a/lib/common/entropy_common.c b/lib/common/entropy_common.c index b42acb4a3..ae6a2fb96 100644 --- a/lib/common/entropy_common.c +++ b/lib/common/entropy_common.c @@ -63,7 +63,7 @@ const char* HUF_getErrorName(size_t code) { return ERR_getErrorName(code); } /*-************************************************************** * FSE NCount encoding-decoding ****************************************************************/ -static short FSE_abs(short a) { return a<0 ? -a : a; } +static short FSE_abs(short a) { return (short)(a<0 ? -a : a); } size_t FSE_readNCount (short* normalizedCounter, unsigned* maxSVPtr, unsigned* tableLogPtr, const void* headerBuffer, size_t hbSize) diff --git a/lib/compress/fse_compress.c b/lib/compress/fse_compress.c index 192d55026..386b2c010 100644 --- a/lib/compress/fse_compress.c +++ b/lib/compress/fse_compress.c @@ -190,7 +190,7 @@ size_t FSE_NCountWriteBound(unsigned maxSymbolValue, unsigned tableLog) return maxSymbolValue ? maxHeaderSize : FSE_NCOUNTBOUND; /* maxSymbolValue==0 ? use default */ } -static short FSE_abs(short a) { return a<0 ? -a : a; } +static short FSE_abs(short a) { return (short)(a<0 ? -a : a); } static size_t FSE_writeNCount_generic (void* header, size_t headerBufferSize, const short* normalizedCounter, unsigned maxSymbolValue, unsigned tableLog, diff --git a/lib/legacy/zstd_v02.c b/lib/legacy/zstd_v02.c index 89501111e..2d4cfa59c 100644 --- a/lib/legacy/zstd_v02.c +++ b/lib/legacy/zstd_v02.c @@ -1350,7 +1350,7 @@ static unsigned FSE_isError(size_t code) { return ERR_isError(code); } ****************************************************************/ static short FSE_abs(short a) { - return a<0 ? -a : a; + return (short)(a<0 ? -a : a); } static size_t FSE_readNCount (short* normalizedCounter, unsigned* maxSVPtr, unsigned* tableLogPtr, diff --git a/lib/zstd.h b/lib/zstd.h index c5efa5d31..36935f77c 100644 --- a/lib/zstd.h +++ b/lib/zstd.h @@ -72,7 +72,7 @@ ZSTDLIB_API unsigned ZSTD_versionNumber (void); /*! ZSTD_compress() : Compresses `src` buffer into already allocated `dst`. Hint : compression runs faster if `dstCapacity` >= `ZSTD_compressBound(srcSize)`. - @return : the number of bytes written into `dst`, + @return : the number of bytes written into `dst` (<= `dstCapacity), or an error code if it fails (which can be tested using ZSTD_isError()) */ ZSTDLIB_API size_t ZSTD_compress( void* dst, size_t dstCapacity, const void* src, size_t srcSize, @@ -80,7 +80,9 @@ ZSTDLIB_API size_t ZSTD_compress( void* dst, size_t dstCapacity, /*! ZSTD_getDecompressedSize() : * @return : decompressed size if known, 0 otherwise. - note : if `0`, follow up with ZSTD_getFrameParams() to know precise failure cause */ + note 1 : if `0`, follow up with ZSTD_getFrameParams() to know precise failure cause. + note 2 : decompressed size could be wrong or intentionally modified ! + always ensure results fit within application's authorized limits */ unsigned long long ZSTD_getDecompressedSize(const void* src, size_t srcSize); /*! ZSTD_decompress() : @@ -106,7 +108,7 @@ ZSTDLIB_API ZSTD_CCtx* ZSTD_createCCtx(void); ZSTDLIB_API size_t ZSTD_freeCCtx(ZSTD_CCtx* cctx); /*!< @return : errorCode */ /** ZSTD_compressCCtx() : - Same as ZSTD_compress(), but requires an allocated ZSTD_CCtx (see ZSTD_createCCtx()) */ + Same as ZSTD_compress(), requires an allocated ZSTD_CCtx (see ZSTD_createCCtx()) */ ZSTDLIB_API size_t ZSTD_compressCCtx(ZSTD_CCtx* ctx, void* dst, size_t dstCapacity, const void* src, size_t srcSize, int compressionLevel); /** Decompression context */ @@ -115,7 +117,7 @@ ZSTDLIB_API ZSTD_DCtx* ZSTD_createDCtx(void); ZSTDLIB_API size_t ZSTD_freeDCtx(ZSTD_DCtx* dctx); /*!< @return : errorCode */ /** ZSTD_decompressDCtx() : -* Same as ZSTD_decompress(), but requires an allocated ZSTD_DCtx (see ZSTD_createDCtx()) */ +* Same as ZSTD_decompress(), requires an allocated ZSTD_DCtx (see ZSTD_createDCtx()) */ ZSTDLIB_API size_t ZSTD_decompressDCtx(ZSTD_DCtx* ctx, void* dst, size_t dstCapacity, const void* src, size_t srcSize); @@ -439,14 +441,13 @@ ZSTDLIB_API size_t ZSTD_decompressContinue(ZSTD_DCtx* dctx, void* dst, size_t ds + ZSTD_decompressBlock() doesn't accept uncompressed data as input !!! + In case of multiple successive blocks, decoder must be informed of uncompressed block existence to follow proper history. Use ZSTD_insertBlock() in such a case. - Insert block once it's copied into its final position. */ #define ZSTD_BLOCKSIZE_ABSOLUTEMAX (128 * 1024) /* define, for static allocation */ ZSTDLIB_API size_t ZSTD_getBlockSizeMax(ZSTD_CCtx* cctx); ZSTDLIB_API size_t ZSTD_compressBlock (ZSTD_CCtx* cctx, void* dst, size_t dstCapacity, const void* src, size_t srcSize); ZSTDLIB_API size_t ZSTD_decompressBlock(ZSTD_DCtx* dctx, void* dst, size_t dstCapacity, const void* src, size_t srcSize); -ZSTDLIB_API size_t ZSTD_insertBlock(ZSTD_DCtx* dctx, const void* blockStart, size_t blockSize); /**< insert block into `dctx` history. Useful to track uncompressed blocks */ +ZSTDLIB_API size_t ZSTD_insertBlock(ZSTD_DCtx* dctx, const void* blockStart, size_t blockSize); /**< insert block into `dctx` history. Useful for uncompressed blocks */ #endif /* ZSTD_STATIC_LINKING_ONLY */