summaryrefslogtreecommitdiffstats
path: root/lib/lz4.h
diff options
context:
space:
mode:
authorW. Felix Handte <w@felixhandte.com>2018-05-03 03:29:07 (GMT)
committerW. Felix Handte <w@felixhandte.com>2018-05-03 04:03:20 (GMT)
commit5406c2e479f5bb2b594a43e74e28719f4640450f (patch)
tree7f35d59a31636f14a4c26c41675acbb33890ebbd /lib/lz4.h
parentc32e0319a5a8319599f0f3d1a510431bdaafbdb1 (diff)
downloadlz4-5406c2e479f5bb2b594a43e74e28719f4640450f.zip
lz4-5406c2e479f5bb2b594a43e74e28719f4640450f.tar.gz
lz4-5406c2e479f5bb2b594a43e74e28719f4640450f.tar.bz2
Only Reset the LZ4 Stream when Init'ing a Streaming Block
Diffstat (limited to 'lib/lz4.h')
-rw-r--r--lib/lz4.h24
1 files changed, 19 insertions, 5 deletions
diff --git a/lib/lz4.h b/lib/lz4.h
index db6353c..d8238f5 100644
--- a/lib/lz4.h
+++ b/lib/lz4.h
@@ -358,6 +358,15 @@ LZ4LIB_API int LZ4_decompress_fast_usingDict (const char* src, char* dst, int or
#ifdef LZ4_STATIC_LINKING_ONLY
/*! LZ4_resetStream_fast() :
+ * Use this, like LZ4_resetStream(), to prepare a context for a new chain of
+ * calls to a streaming API (e.g., LZ4_compress_fast_continue()).
+ *
+ * Note:
+ * Using this in advance of a non- streaming-compression function is redundant,
+ * and potentially bad for performance, since they all perform their own custom
+ * reset internally.
+ *
+ * Differences from LZ4_resetStream():
* When an LZ4_stream_t is known to be in a internally coherent state,
* it can often be prepared for a new compression with almost no work, only
* sometimes falling back to the full, expensive reset that is always required
@@ -367,13 +376,17 @@ LZ4LIB_API int LZ4_decompress_fast_usingDict (const char* src, char* dst, int or
* LZ4_streams are guaranteed to be in a valid state when:
* - returned from LZ4_createStream()
* - reset by LZ4_resetStream()
- * - memset(stream, 0, sizeof(LZ4_stream_t))
+ * - memset(stream, 0, sizeof(LZ4_stream_t)), though this is discouraged
* - the stream was in a valid state and was reset by LZ4_resetStream_fast()
* - the stream was in a valid state and was then used in any compression call
* that returned success
* - the stream was in an indeterminate state and was used in a compression
- * call that fully reset the state (LZ4_compress_fast_extState()) and that
- * returned success
+ * call that fully reset the state (e.g., LZ4_compress_fast_extState()) and
+ * that returned success
+ *
+ * When a stream isn't known to be in a valid state, it is not safe to pass to
+ * any fastReset or streaming function. It must first be cleansed by the full
+ * LZ4_resetStream().
*/
LZ4LIB_API void LZ4_resetStream_fast (LZ4_stream_t* streamPtr);
@@ -384,8 +397,9 @@ LZ4LIB_API void LZ4_resetStream_fast (LZ4_stream_t* streamPtr);
* to call if the state buffer is known to be correctly initialized already
* (see above comment on LZ4_resetStream_fast() for a definition of "correctly
* initialized"). From a high level, the difference is that this function
- * initializes the provided state with a call to LZ4_resetStream_fast() while
- * LZ4_compress_fast_extState() starts with a call to LZ4_resetStream().
+ * initializes the provided state with a call to something like
+ * LZ4_resetStream_fast() while LZ4_compress_fast_extState() starts with a
+ * call to LZ4_resetStream().
*/
LZ4LIB_API int LZ4_compress_fast_extState_fastReset (void* state, const char* src, char* dst, int srcSize, int dstCapacity, int acceleration);