summaryrefslogtreecommitdiffstats
path: root/lib/lz4.c
diff options
context:
space:
mode:
authorYann Collet <yann.collet.73@gmail.com>2015-04-23 06:46:35 (GMT)
committerYann Collet <yann.collet.73@gmail.com>2015-04-23 06:46:35 (GMT)
commit9c6fb8b160e72454cb50ca78ceca428cb246fd8a (patch)
tree208ba9019adb4d938b5a8cb92cbadc032ac6771b /lib/lz4.c
parentb05d3d71a6ae2a0f711dfa0a046b8b0095978045 (diff)
downloadlz4-9c6fb8b160e72454cb50ca78ceca428cb246fd8a.zip
lz4-9c6fb8b160e72454cb50ca78ceca428cb246fd8a.tar.gz
lz4-9c6fb8b160e72454cb50ca78ceca428cb246fd8a.tar.bz2
Added LZ4_compress_fast_extState()
Diffstat (limited to 'lib/lz4.c')
-rw-r--r--lib/lz4.c34
1 files changed, 18 insertions, 16 deletions
diff --git a/lib/lz4.c b/lib/lz4.c
index 490f9ce..e9fe467 100644
--- a/lib/lz4.c
+++ b/lib/lz4.c
@@ -697,29 +697,36 @@ int LZ4_compress_safe(const char* source, char* dest, int inputSize, int maxOutp
}
-int LZ4_compress_fast(const char* source, char* dest, int inputSize, int maxOutputSize, unsigned acceleration)
+int LZ4_compress_fast_extState(void* state, const char* source, char* dest, int inputSize, int maxOutputSize, unsigned acceleration)
{
-#if (HEAPMODE)
- void* ctx = ALLOCATOR(LZ4_STREAMSIZE_U64, 8); /* Aligned on 8-bytes boundaries */
-#else
- U64 ctx[LZ4_STREAMSIZE_U64] = {0}; /* Ensure data is aligned on 8-bytes boundaries */
-#endif
- int result;
+ MEM_INIT(state, 0, LZ4_STREAMSIZE);
if (acceleration == 0)
{
if (inputSize < LZ4_64Klimit)
- result = LZ4_compress_generic((void*)ctx, source, dest, inputSize, maxOutputSize, limitedOutput, byU16, noDict, noDictIssue, ACCELERATION_DEFAULT);
+ return LZ4_compress_generic(state, source, dest, inputSize, maxOutputSize, limitedOutput, byU16, noDict, noDictIssue, ACCELERATION_DEFAULT);
else
- result = LZ4_compress_generic((void*)ctx, source, dest, inputSize, maxOutputSize, limitedOutput, LZ4_64bits() ? byU32 : byPtr, noDict, noDictIssue, ACCELERATION_DEFAULT);
+ return LZ4_compress_generic(state, source, dest, inputSize, maxOutputSize, limitedOutput, LZ4_64bits() ? byU32 : byPtr, noDict, noDictIssue, ACCELERATION_DEFAULT);
}
else
{
if (inputSize < LZ4_64Klimit)
- result = LZ4_compress_generic((void*)ctx, source, dest, inputSize, maxOutputSize, limitedOutput, byU16, noDict, noDictIssue, acceleration);
+ return LZ4_compress_generic(state, source, dest, inputSize, maxOutputSize, limitedOutput, byU16, noDict, noDictIssue, acceleration);
else
- result = LZ4_compress_generic((void*)ctx, source, dest, inputSize, maxOutputSize, limitedOutput, LZ4_64bits() ? byU32 : byPtr, noDict, noDictIssue, acceleration);
+ return LZ4_compress_generic(state, source, dest, inputSize, maxOutputSize, limitedOutput, LZ4_64bits() ? byU32 : byPtr, noDict, noDictIssue, acceleration);
}
+}
+
+
+int LZ4_compress_fast(const char* source, char* dest, int inputSize, int maxOutputSize, unsigned acceleration)
+{
+#if (HEAPMODE)
+ void* ctx = ALLOCATOR(LZ4_STREAMSIZE_U64, 8); /* Aligned on 8-bytes boundaries */
+#else
+ U64 ctx[LZ4_STREAMSIZE_U64]; /* Ensure data is aligned on 8-bytes boundaries */
+#endif
+
+ int result = LZ4_compress_fast_extState(ctx, source, dest, inputSize, maxOutputSize, acceleration);
#if (HEAPMODE)
FREEMEM(ctx);
@@ -740,11 +747,6 @@ LZ4_stream_t* LZ4_createStream(void)
return lz4s;
}
-/*
- * LZ4_initStream
- * Use this function once, to init a newly allocated LZ4_stream_t structure
- * Return : 1 if OK, 0 if error
- */
void LZ4_resetStream (LZ4_stream_t* LZ4_stream)
{
MEM_INIT(LZ4_stream, 0, sizeof(LZ4_stream_t));