summaryrefslogtreecommitdiffstats
path: root/lz4hc_encoder.h
diff options
context:
space:
mode:
Diffstat (limited to 'lz4hc_encoder.h')
-rw-r--r--lz4hc_encoder.h21
1 files changed, 14 insertions, 7 deletions
diff --git a/lz4hc_encoder.h b/lz4hc_encoder.h
index 0d10e7c..edee93c 100644
--- a/lz4hc_encoder.h
+++ b/lz4hc_encoder.h
@@ -107,8 +107,8 @@ forceinline static int ENCODE_SEQUENCE_NAME (
}
-int COMBINED_NAME(FUNCTION_NAME,ctx) (
- LZ4HC_Data_Structure* ctx,
+int COMBINED_NAME(FUNCTION_NAME,_continue) (
+ void* ctxvoid,
const char* source,
char* dest,
int inputSize
@@ -116,7 +116,8 @@ int COMBINED_NAME(FUNCTION_NAME,ctx) (
,int maxOutputSize
#endif
)
-{
+{
+ LZ4HC_Data_Structure* ctx = (LZ4HC_Data_Structure*) ctxvoid;
const BYTE* ip = (const BYTE*) source;
const BYTE* anchor = ip;
const BYTE* const iend = ip + inputSize;
@@ -137,6 +138,10 @@ int COMBINED_NAME(FUNCTION_NAME,ctx) (
const BYTE* start0;
const BYTE* ref0;
+ // Ensure blocks follow each other
+ if (ip != ctx->end) return 0;
+ ctx->end += inputSize;
+
ip++;
// Main Loop
@@ -311,13 +316,15 @@ int FUNCTION_NAME (const char* source,
#endif
)
{
- void* ctx = LZ4HC_create((const BYTE*)source);
+ void* ctx = LZ4_createHC(source);
+ int result;
+ if (ctx==NULL) return 0;
#ifdef LIMITED_OUTPUT
- int result = COMBINED_NAME(FUNCTION_NAME,ctx) (ctx, source, dest, inputSize, maxOutputSize);
+ result = COMBINED_NAME(FUNCTION_NAME,_continue) (ctx, source, dest, inputSize, maxOutputSize);
#else
- int result = COMBINED_NAME(FUNCTION_NAME,ctx) (ctx, source, dest, inputSize);
+ result = COMBINED_NAME(FUNCTION_NAME,_continue) (ctx, source, dest, inputSize);
#endif
- LZ4HC_free (&ctx);
+ LZ4_freeHC(ctx);
return result;
}