diff options
author | Yann Collet <cyan@fb.com> | 2018-01-31 22:33:16 (GMT) |
---|---|---|
committer | Yann Collet <cyan@fb.com> | 2018-01-31 22:33:16 (GMT) |
commit | 87fb7a1d031a7e6df72d5ca50ab543a57ddca21f (patch) | |
tree | 4fb328b79a82c18cbb458e677681b80b40bb03d5 /lib | |
parent | 8258f4d9cba4c163f0c63a60a79d14d8aef90c4e (diff) | |
download | lz4-87fb7a1d031a7e6df72d5ca50ab543a57ddca21f.zip lz4-87fb7a1d031a7e6df72d5ca50ab543a57ddca21f.tar.gz lz4-87fb7a1d031a7e6df72d5ca50ab543a57ddca21f.tar.bz2 |
refactored frameCompress example
to better reflect LZ4F API usage.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/lz4frame.c | 3 | ||||
-rw-r--r-- | lib/lz4frame.h | 12 |
2 files changed, 10 insertions, 5 deletions
diff --git a/lib/lz4frame.c b/lib/lz4frame.c index 0b26f75..a394d1f 100644 --- a/lib/lz4frame.c +++ b/lib/lz4frame.c @@ -726,7 +726,8 @@ size_t LZ4F_compressUpdate(LZ4F_cctx* cctxPtr, if (cctxPtr->cStage != 1) return err0r(LZ4F_ERROR_GENERIC); - if (dstCapacity < LZ4F_compressBound_internal(srcSize, &(cctxPtr->prefs), cctxPtr->tmpInSize)) return err0r(LZ4F_ERROR_dstMaxSize_tooSmall); + if (dstCapacity < LZ4F_compressBound_internal(srcSize, &(cctxPtr->prefs), cctxPtr->tmpInSize)) + return err0r(LZ4F_ERROR_dstMaxSize_tooSmall); memset(&cOptionsNull, 0, sizeof(cOptionsNull)); if (compressOptionsPtr == NULL) compressOptionsPtr = &cOptionsNull; diff --git a/lib/lz4frame.h b/lib/lz4frame.h index eb55e45..15484d7 100644 --- a/lib/lz4frame.h +++ b/lib/lz4frame.h @@ -189,8 +189,10 @@ LZ4FLIB_API int LZ4F_compressionLevel_max(void); * Simple compression function ***********************************/ /*! LZ4F_compressFrameBound() : - * Returns the maximum possible size of a frame compressed with LZ4F_compressFrame() given srcSize content and preferences. - * Note : this result is only usable with LZ4F_compressFrame(), not with multi-segments compression. + * Returns the maximum possible compressed size with LZ4F_compressFrame() given srcSize and preferences. + * `preferencesPtr` is optional. It can be replaced by NULL, in which case, the function will assume default preferences. + * Note : this result is only usable with LZ4F_compressFrame(). + * It may also be used with LZ4F_compressUpdate() _if no flush() operation_ is performed. */ LZ4FLIB_API size_t LZ4F_compressFrameBound(size_t srcSize, const LZ4F_preferences_t* preferencesPtr); @@ -235,7 +237,7 @@ LZ4FLIB_API LZ4F_errorCode_t LZ4F_freeCompressionContext(LZ4F_cctx* cctx); /*---- Compression ----*/ -#define LZ4F_HEADER_SIZE_MAX 19 +#define LZ4F_HEADER_SIZE_MAX 19 /* LZ4 Frame header size can vary from 7 to 19 bytes */ /*! LZ4F_compressBegin() : * will write the frame header into dstBuffer. * dstCapacity must be >= LZ4F_HEADER_SIZE_MAX bytes. @@ -248,7 +250,9 @@ LZ4FLIB_API size_t LZ4F_compressBegin(LZ4F_cctx* cctx, const LZ4F_preferences_t* prefsPtr); /*! LZ4F_compressBound() : - * Provides minimum dstCapacity for a given srcSize to guarantee operation success in worst case situations. + * Provides minimum dstCapacity for a given srcSize to guarantee operation success in worst case scenarios. + * Estimation includes frame footer, which would be generated by LZ4F_compressEnd(). + * Estimation doesn't include frame header, already generated by LZ4F_compressBegin(). * prefsPtr is optional : when NULL is provided, preferences will be set to cover worst case scenario. * Result is always the same for a srcSize and prefsPtr, so it can be trusted to size reusable buffers. * When srcSize==0, LZ4F_compressBound() provides an upper bound for LZ4F_flush() and LZ4F_compressEnd() operations. |