aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/libs/lz4/lz4hc.c
diff options
context:
space:
mode:
authorRuslan Kovalev <ruslan.a.kovalev@gmail.com>2022-02-10 16:46:44 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:46:44 +0300
commit59e19371de37995fcb36beb16cd6ec030af960bc (patch)
treefa68e36093ebff8b805462e9e6d331fe9d348214 /contrib/libs/lz4/lz4hc.c
parent89db6fe2fe2c32d2a832ddfeb04e8d078e301084 (diff)
downloadydb-59e19371de37995fcb36beb16cd6ec030af960bc.tar.gz
Restoring authorship annotation for Ruslan Kovalev <ruslan.a.kovalev@gmail.com>. Commit 1 of 2.
Diffstat (limited to 'contrib/libs/lz4/lz4hc.c')
-rw-r--r--contrib/libs/lz4/lz4hc.c218
1 files changed, 109 insertions, 109 deletions
diff --git a/contrib/libs/lz4/lz4hc.c b/contrib/libs/lz4/lz4hc.c
index a556d47920..067b4dfedd 100644
--- a/contrib/libs/lz4/lz4hc.c
+++ b/contrib/libs/lz4/lz4hc.c
@@ -1,20 +1,20 @@
-/*
+/*
LZ4 HC - High Compression Mode of LZ4
Copyright (C) 2011-2017, Yann Collet.
-
+
BSD 2-Clause License (http://www.opensource.org/licenses/bsd-license.php)
-
+
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
-
+
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following disclaimer
in the documentation and/or other materials provided with the
distribution.
-
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
@@ -30,14 +30,14 @@
You can contact the author at :
- LZ4 source repository : https://github.com/lz4/lz4
- LZ4 public forum : https://groups.google.com/forum/#!forum/lz4c
-*/
+*/
/* note : lz4hc is not an independent module, it requires lz4.h/lz4.c for proper compilation */
-
-
+
+
/* *************************************
* Tuning Parameter
***************************************/
-
+
/*! HEAPMODE :
* Select how default compression function will allocate workplace memory,
* in stack (0:fastest), or in heap (1:requires malloc()).
@@ -45,27 +45,27 @@
*/
#ifndef LZ4HC_HEAPMODE
# define LZ4HC_HEAPMODE 1
-#endif
-
-
+#endif
+
+
/*=== Dependency ===*/
#define LZ4_HC_STATIC_LINKING_ONLY
#include "lz4hc.h"
-
-
+
+
/*=== Common definitions ===*/
#if defined(__GNUC__)
# pragma GCC diagnostic ignored "-Wunused-function"
-#endif
+#endif
#if defined (__clang__)
# pragma clang diagnostic ignored "-Wunused-function"
-#endif
-
+#endif
+
#define LZ4_COMMONDEFS_ONLY
#ifndef LZ4_SRC_INCLUDED
#include "lz4.c" /* LZ4_count, constants, mem */
#endif
-
+
/*=== Enums ===*/
typedef enum { noDictCtx, usingDictCtxHc } dictCtx_directive;
@@ -74,8 +74,8 @@ typedef enum { noDictCtx, usingDictCtxHc } dictCtx_directive;
/*=== Constants ===*/
#define OPTIMAL_ML (int)((ML_MASK-1)+MINMATCH)
#define LZ4_OPT_NUM (1<<12)
-
-
+
+
/*=== Macros ===*/
#define MIN(a,b) ( (a) < (b) ? (a) : (b) )
#define MAX(a,b) ( (a) > (b) ? (a) : (b) )
@@ -84,10 +84,10 @@ typedef enum { noDictCtx, usingDictCtxHc } dictCtx_directive;
#define DELTANEXTU16(table, pos) table[(U16)(pos)] /* faster */
/* Make fields passed to, and updated by LZ4HC_encodeSequence explicit */
#define UPDATABLE(ip, op, anchor) &ip, &op, &anchor
-
+
static U32 LZ4HC_hashPtr(const void* ptr) { return HASH_FUNCTION(LZ4_read32(ptr)); }
-
-
+
+
/**************************************
* HC Compression
**************************************/
@@ -112,8 +112,8 @@ static void LZ4HC_init_internal (LZ4HC_CCtx_internal* hc4, const BYTE* start)
hc4->dictLimit = (U32) startingOffset;
hc4->lowLimit = (U32) startingOffset;
}
-
-
+
+
/* Update chains up to ip (excluded) */
LZ4_FORCE_INLINE void LZ4HC_Insert (LZ4HC_CCtx_internal* hc4, const BYTE* ip)
{
@@ -122,7 +122,7 @@ LZ4_FORCE_INLINE void LZ4HC_Insert (LZ4HC_CCtx_internal* hc4, const BYTE* ip)
const BYTE* const base = hc4->base;
U32 const target = (U32)(ip - base);
U32 idx = hc4->nextToUpdate;
-
+
while (idx < target) {
U32 const h = LZ4HC_hashPtr(base+idx);
size_t delta = idx - hashTable[h];
@@ -131,10 +131,10 @@ LZ4_FORCE_INLINE void LZ4HC_Insert (LZ4HC_CCtx_internal* hc4, const BYTE* ip)
hashTable[h] = idx;
idx++;
}
-
+
hc4->nextToUpdate = target;
}
-
+
/** LZ4HC_countBack() :
* @return : negative value, nb of common bytes before ip/match */
LZ4_FORCE_INLINE
@@ -151,7 +151,7 @@ int LZ4HC_countBack(const BYTE* const ip, const BYTE* const match,
back--;
return back;
}
-
+
#if defined(_MSC_VER)
# define LZ4HC_rotl32(x,r) _rotl(x,r)
#else
@@ -174,14 +174,14 @@ LZ4HC_countPattern(const BYTE* ip, const BYTE* const iEnd, U32 const pattern32)
const BYTE* const iStart = ip;
reg_t const pattern = (sizeof(pattern)==8) ?
(reg_t)pattern32 + (((reg_t)pattern32) << (sizeof(pattern)*4)) : pattern32;
-
+
while (likely(ip < iEnd-(sizeof(pattern)-1))) {
reg_t const diff = LZ4_read_ARCH(ip) ^ pattern;
if (!diff) { ip+=sizeof(pattern); continue; }
ip += LZ4_NbCommonBytes(diff);
return (unsigned)(ip - iStart);
}
-
+
if (LZ4_isLittleEndian()) {
reg_t patternByte = pattern;
while ((ip<iEnd) && (*ip == (BYTE)patternByte)) {
@@ -195,10 +195,10 @@ LZ4HC_countPattern(const BYTE* ip, const BYTE* const iEnd, U32 const pattern32)
ip ++; bitOffset -= 8;
}
}
-
+
return (unsigned)(ip - iStart);
}
-
+
/* LZ4HC_reverseCountPattern() :
* pattern must be a sample of repetitive pattern of length 1, 2 or 4 (but not 3!)
* read using natural platform endianess */
@@ -206,7 +206,7 @@ static unsigned
LZ4HC_reverseCountPattern(const BYTE* ip, const BYTE* const iLow, U32 pattern)
{
const BYTE* const iStart = ip;
-
+
while (likely(ip >= iLow+4)) {
if (LZ4_read32(ip-4) != pattern) break;
ip -= 4;
@@ -246,7 +246,7 @@ LZ4HC_InsertAndGetWiderMatch (
const int chainSwap,
const dictCtx_directive dict,
const HCfavor_e favorDecSpeed)
-{
+{
U16* const chainTable = hc4->chainTable;
U32* const HashTable = hc4->hashTable;
const LZ4HC_CCtx_internal * const dictCtx = hc4->dictCtx;
@@ -263,14 +263,14 @@ LZ4HC_InsertAndGetWiderMatch (
U32 matchIndex;
repeat_state_e repeat = rep_untested;
size_t srcPatternLength = 0;
-
+
DEBUGLOG(7, "LZ4HC_InsertAndGetWiderMatch");
/* First Match */
LZ4HC_Insert(hc4, ip);
matchIndex = HashTable[LZ4HC_hashPtr(ip)];
DEBUGLOG(7, "First match at index %u / %u (lowestMatchIndex)",
matchIndex, lowestMatchIndex);
-
+
while ((matchIndex>=lowestMatchIndex) && (nbAttempts>0)) {
int matchLength=0;
nbAttempts--;
@@ -309,7 +309,7 @@ LZ4HC_InsertAndGetWiderMatch (
*matchpos = base + matchIndex + back; /* virtual pos, relative to ip, to retrieve offset */
*startpos = ip + back;
} } }
-
+
if (chainSwap && matchLength==longest) { /* better match => select a better chain */
assert(lookBackLength==0); /* search forward only */
if (matchIndex + (U32)longest <= ipIndex) {
@@ -333,7 +333,7 @@ LZ4HC_InsertAndGetWiderMatch (
matchIndex -= distanceToNextMatch;
continue;
} } }
-
+
{ U32 const distNextMatch = DELTANEXTU16(chainTable, matchIndex);
if (patternAnalysis && distNextMatch==1 && matchChainPos==0) {
U32 const matchCandidateIdx = matchIndex-1;
@@ -440,8 +440,8 @@ LZ4HC_InsertAndGetWiderMatch (
} } }
return longest;
-}
-
+}
+
LZ4_FORCE_INLINE
int LZ4HC_InsertAndFindBestMatch(LZ4HC_CCtx_internal* const hc4, /* Index table will be updated */
const BYTE* const ip, const BYTE* const iLimit,
@@ -456,7 +456,7 @@ int LZ4HC_InsertAndFindBestMatch(LZ4HC_CCtx_internal* const hc4, /* Index tabl
* so LZ4HC_InsertAndGetWiderMatch() won't be allowed to search past ip */
return LZ4HC_InsertAndGetWiderMatch(hc4, ip, ip, iLimit, MINMATCH-1, matchpos, &uselessPtr, maxNbAttempts, patternAnalysis, 0 /*chainSwap*/, dict, favorCompressionRatio);
}
-
+
/* LZ4HC_encodeSequence() :
* @return : 0 if ok,
* 1 if buffer issue detected */
@@ -491,8 +491,8 @@ LZ4_FORCE_INLINE int LZ4HC_encodeSequence (
(U32)(ip - anchor), matchLength, (U32)(ip-match),
cost, totalCost);
totalCost += cost;
-#endif
-
+#endif
+
/* Encode Literal length */
length = (size_t)(ip - anchor);
LZ4_STATIC_ASSERT(notLimited == 0);
@@ -510,15 +510,15 @@ LZ4_FORCE_INLINE int LZ4HC_encodeSequence (
} else {
*token = (BYTE)(length << ML_BITS);
}
-
+
/* Copy Literals */
LZ4_wildCopy8(op, anchor, op + length);
op += length;
-
+
/* Encode Offset */
assert( (ip - match) <= LZ4_DISTANCE_MAX ); /* note : consider providing offset as a value, rather than as a pointer difference */
LZ4_writeLE16(op, (U16)(ip - match)); op += 2;
-
+
/* Encode MatchLength */
assert(matchLength >= MINMATCH);
length = (size_t)matchLength - MINMATCH;
@@ -535,17 +535,17 @@ LZ4_FORCE_INLINE int LZ4HC_encodeSequence (
} else {
*token += (BYTE)(length);
}
-
+
/* Prepare next loop */
ip += matchLength;
anchor = ip;
return 0;
-}
+}
#undef ip
#undef op
#undef anchor
-
+
LZ4_FORCE_INLINE int LZ4HC_compress_hashChain (
LZ4HC_CCtx_internal* const ctx,
const char* const source,
@@ -556,7 +556,7 @@ LZ4_FORCE_INLINE int LZ4HC_compress_hashChain (
const limitedOutput_directive limit,
const dictCtx_directive dict
)
-{
+{
const int inputSize = *srcSizePtr;
const int patternAnalysis = (maxNbAttempts > 128); /* levels 9+ */
@@ -565,11 +565,11 @@ LZ4_FORCE_INLINE int LZ4HC_compress_hashChain (
const BYTE* const iend = ip + inputSize;
const BYTE* const mflimit = iend - MFLIMIT;
const BYTE* const matchlimit = (iend - LASTLITERALS);
-
+
BYTE* optr = (BYTE*) dest;
BYTE* op = (BYTE*) dest;
BYTE* oend = op + maxOutputSize;
-
+
int ml0, ml, ml2, ml3;
const BYTE* start0;
const BYTE* ref0;
@@ -578,20 +578,20 @@ LZ4_FORCE_INLINE int LZ4HC_compress_hashChain (
const BYTE* ref2 = NULL;
const BYTE* start3 = NULL;
const BYTE* ref3 = NULL;
-
+
/* init */
*srcSizePtr = 0;
if (limit == fillOutput) oend -= LASTLITERALS; /* Hack for support LZ4 format restriction */
if (inputSize < LZ4_minLength) goto _last_literals; /* Input too small, no compression (all literals) */
-
+
/* Main Loop */
while (ip <= mflimit) {
ml = LZ4HC_InsertAndFindBestMatch(ctx, ip, matchlimit, &ref, maxNbAttempts, patternAnalysis, dict);
if (ml<MINMATCH) { ip++; continue; }
-
+
/* saved, in case we would skip too much */
start0 = ip; ref0 = ref; ml0 = ml;
-
+
_Search2:
if (ip+ml <= mflimit) {
ml2 = LZ4HC_InsertAndGetWiderMatch(ctx,
@@ -600,18 +600,18 @@ _Search2:
} else {
ml2 = ml;
}
-
+
if (ml2 == ml) { /* No better match => encode ML1 */
optr = op;
if (LZ4HC_encodeSequence(UPDATABLE(ip, op, anchor), ml, ref, limit, oend)) goto _dest_overflow;
continue;
}
-
+
if (start0 < ip) { /* first match was skipped at least once */
if (start2 < ip + ml0) { /* squeezing ML1 between ML0(original ML1) and ML2 */
ip = start0; ref = ref0; ml = ml0; /* restore initial ML1 */
} }
-
+
/* Here, start0==ip */
if ((start2 - ip) < 3) { /* First Match too small : removed */
ml = ml2;
@@ -619,7 +619,7 @@ _Search2:
ref =ref2;
goto _Search2;
}
-
+
_Search3:
/* At this stage, we have :
* ml2 > ml1, and
@@ -637,7 +637,7 @@ _Search3:
}
}
/* Now, we have start2 = ip+new_ml, with new_ml = min(ml, OPTIMAL_ML=18) */
-
+
if (start2 + ml2 <= mflimit) {
ml3 = LZ4HC_InsertAndGetWiderMatch(ctx,
start2 + ml2 - 3, start2, matchlimit, ml2, &ref3, &start3,
@@ -645,7 +645,7 @@ _Search3:
} else {
ml3 = ml2;
}
-
+
if (ml3 == ml2) { /* No better match => encode ML1 and ML2 */
/* ip & ref are known; Now for ml */
if (start2 < ip+ml) ml = (int)(start2 - ip);
@@ -661,7 +661,7 @@ _Search3:
}
continue;
}
-
+
if (start3 < ip+ml+3) { /* Not enough space for match 2 : remove it */
if (start3 >= (ip+ml)) { /* can write Seq1 immediately ==> Seq2 is removed, so Seq3 becomes Seq1 */
if (start2 < ip+ml) {
@@ -675,25 +675,25 @@ _Search3:
ml2 = ml3;
}
}
-
+
optr = op;
if (LZ4HC_encodeSequence(UPDATABLE(ip, op, anchor), ml, ref, limit, oend)) goto _dest_overflow;
ip = start3;
ref = ref3;
ml = ml3;
-
+
start0 = start2;
ref0 = ref2;
ml0 = ml2;
goto _Search2;
}
-
+
start2 = start3;
ref2 = ref3;
ml2 = ml3;
goto _Search3;
}
-
+
/*
* OK, now we have 3 ascending matches;
* let's write the first one ML1.
@@ -716,17 +716,17 @@ _Search3:
}
optr = op;
if (LZ4HC_encodeSequence(UPDATABLE(ip, op, anchor), ml, ref, limit, oend)) goto _dest_overflow;
-
+
/* ML2 becomes ML1 */
ip = start2; ref = ref2; ml = ml2;
-
+
/* ML3 becomes ML2 */
start2 = start3; ref2 = ref3; ml2 = ml3;
-
+
/* let's find a new ML3 */
goto _Search3;
}
-
+
_last_literals:
/* Encode Last Literals */
{ size_t lastRunSize = (size_t)(iend - anchor); /* literals */
@@ -754,11 +754,11 @@ _last_literals:
memcpy(op, anchor, lastRunSize);
op += lastRunSize;
}
-
+
/* End */
*srcSizePtr = (int) (((const char*)ip) - source);
return (int) (((char*)op)-dest);
-
+
_dest_overflow:
if (limit == fillOutput) {
/* Assumption : ip, anchor, ml and ref must be set correctly */
@@ -782,7 +782,7 @@ _dest_overflow:
/* compression failed */
return 0;
}
-
+
static int LZ4HC_compress_optimal( LZ4HC_CCtx_internal* ctx,
const char* const source, char* dst,
@@ -854,10 +854,10 @@ LZ4_FORCE_INLINE int LZ4HC_compress_generic_internal (
if (result <= 0) ctx->dirty = 1;
return result;
}
-}
-
+}
+
static void LZ4HC_setExternalDict(LZ4HC_CCtx_internal* ctxPtr, const BYTE* newBlock);
-
+
static int
LZ4HC_compress_generic_noDictCtx (
LZ4HC_CCtx_internal* const ctx,
@@ -872,7 +872,7 @@ LZ4HC_compress_generic_noDictCtx (
assert(ctx->dictCtx == NULL);
return LZ4HC_compress_generic_internal(ctx, src, dst, srcSizePtr, dstCapacity, cLevel, limit, noDictCtx);
}
-
+
static int
LZ4HC_compress_generic_dictCtx (
LZ4HC_CCtx_internal* const ctx,
@@ -943,7 +943,7 @@ int LZ4_compress_HC_extStateHC_fastReset (void* state, const char* src, char* ds
else
return LZ4HC_compress_generic (ctx, src, dst, &srcSize, dstCapacity, compressionLevel, notLimited);
}
-
+
int LZ4_compress_HC_extStateHC (void* state, const char* src, char* dst, int srcSize, int dstCapacity, int compressionLevel)
{
LZ4_streamHC_t* const ctx = LZ4_initStreamHC(state, sizeof(*ctx));
@@ -965,7 +965,7 @@ int LZ4_compress_HC(const char* src, char* dst, int srcSize, int dstCapacity, in
#endif
return cSize;
}
-
+
/* state is presumed sized correctly (>= sizeof(LZ4_streamHC_t)) */
int LZ4_compress_HC_destSize(void* state, const char* source, char* dest, int* sourceSizePtr, int targetDestSize, int cLevel)
{
@@ -975,8 +975,8 @@ int LZ4_compress_HC_destSize(void* state, const char* source, char* dest, int* s
LZ4_setCompressionLevel(ctx, cLevel);
return LZ4HC_compress_generic(&ctx->internal_donotuse, source, dest, sourceSizePtr, targetDestSize, cLevel, fillOutput);
}
-
-
+
+
/**************************************
* Streaming Functions
@@ -990,7 +990,7 @@ LZ4_streamHC_t* LZ4_createStreamHC(void)
LZ4_setCompressionLevel(state, LZ4HC_CLEVEL_DEFAULT);
return state;
}
-
+
int LZ4_freeStreamHC (LZ4_streamHC_t* LZ4_streamHCPtr)
{
DEBUGLOG(4, "LZ4_freeStreamHC(%p)", LZ4_streamHCPtr);
@@ -998,7 +998,7 @@ int LZ4_freeStreamHC (LZ4_streamHC_t* LZ4_streamHCPtr)
FREEMEM(LZ4_streamHCPtr);
return 0;
}
-
+
LZ4_streamHC_t* LZ4_initStreamHC (void* buffer, size_t size)
{
@@ -1016,7 +1016,7 @@ LZ4_streamHC_t* LZ4_initStreamHC (void* buffer, size_t size)
LZ4_setCompressionLevel(LZ4_streamHCPtr, LZ4HC_CLEVEL_DEFAULT);
return LZ4_streamHCPtr;
}
-
+
/* just a stub */
void LZ4_resetStreamHC (LZ4_streamHC_t* LZ4_streamHCPtr, int compressionLevel)
{
@@ -1077,19 +1077,19 @@ int LZ4_loadDictHC (LZ4_streamHC_t* LZ4_streamHCPtr,
if (dictSize >= 4) LZ4HC_Insert (ctxPtr, ctxPtr->end-3);
return dictSize;
}
-
+
void LZ4_attach_HC_dictionary(LZ4_streamHC_t *working_stream, const LZ4_streamHC_t *dictionary_stream) {
working_stream->internal_donotuse.dictCtx = dictionary_stream != NULL ? &(dictionary_stream->internal_donotuse) : NULL;
}
-
+
/* compression */
-
+
static void LZ4HC_setExternalDict(LZ4HC_CCtx_internal* ctxPtr, const BYTE* newBlock)
{
DEBUGLOG(4, "LZ4HC_setExternalDict(%p, %p)", ctxPtr, newBlock);
if (ctxPtr->end >= ctxPtr->base + ctxPtr->dictLimit + 4)
LZ4HC_Insert (ctxPtr, ctxPtr->end-3); /* Referencing remaining dictionary content */
-
+
/* Only one memory segment for extDict, so any previous extDict is lost at this stage */
ctxPtr->lowLimit = ctxPtr->dictLimit;
ctxPtr->dictLimit = (U32)(ctxPtr->end - ctxPtr->base);
@@ -1101,7 +1101,7 @@ static void LZ4HC_setExternalDict(LZ4HC_CCtx_internal* ctxPtr, const BYTE* newBl
/* cannot reference an extDict and a dictCtx at the same time */
ctxPtr->dictCtx = NULL;
}
-
+
static int
LZ4_compressHC_continue_generic (LZ4_streamHC_t* LZ4_streamHCPtr,
const char* src, char* dst,
@@ -1114,18 +1114,18 @@ LZ4_compressHC_continue_generic (LZ4_streamHC_t* LZ4_streamHCPtr,
assert(ctxPtr != NULL);
/* auto-init if forgotten */
if (ctxPtr->base == NULL) LZ4HC_init_internal (ctxPtr, (const BYTE*) src);
-
+
/* Check overflow */
if ((size_t)(ctxPtr->end - ctxPtr->base) > 2 GB) {
size_t dictSize = (size_t)(ctxPtr->end - ctxPtr->base) - ctxPtr->dictLimit;
if (dictSize > 64 KB) dictSize = 64 KB;
LZ4_loadDictHC(LZ4_streamHCPtr, (const char*)(ctxPtr->end) - dictSize, (int)dictSize);
}
-
+
/* Check if blocks follow each other */
if ((const BYTE*)src != ctxPtr->end)
LZ4HC_setExternalDict(ctxPtr, (const BYTE*)src);
-
+
/* Check overlapping input/dictionary space */
{ const BYTE* sourceEnd = (const BYTE*) src + *srcSizePtr;
const BYTE* const dictBegin = ctxPtr->dictBase + ctxPtr->lowLimit;
@@ -1135,10 +1135,10 @@ LZ4_compressHC_continue_generic (LZ4_streamHC_t* LZ4_streamHCPtr,
ctxPtr->lowLimit = (U32)(sourceEnd - ctxPtr->dictBase);
if (ctxPtr->dictLimit - ctxPtr->lowLimit < 4) ctxPtr->lowLimit = ctxPtr->dictLimit;
} }
-
+
return LZ4HC_compress_generic (ctxPtr, src, dst, srcSizePtr, dstCapacity, ctxPtr->compressionLevel, limit);
}
-
+
int LZ4_compress_HC_continue (LZ4_streamHC_t* LZ4_streamHCPtr, const char* src, char* dst, int srcSize, int dstCapacity)
{
if (dstCapacity < LZ4_compressBound(srcSize))
@@ -1146,12 +1146,12 @@ int LZ4_compress_HC_continue (LZ4_streamHC_t* LZ4_streamHCPtr, const char* src,
else
return LZ4_compressHC_continue_generic (LZ4_streamHCPtr, src, dst, &srcSize, dstCapacity, notLimited);
}
-
+
int LZ4_compress_HC_continue_destSize (LZ4_streamHC_t* LZ4_streamHCPtr, const char* src, char* dst, int* srcSizePtr, int targetDestSize)
{
return LZ4_compressHC_continue_generic(LZ4_streamHCPtr, src, dst, srcSizePtr, targetDestSize, fillOutput);
}
-
+
/* LZ4_saveDictHC :
@@ -1181,8 +1181,8 @@ int LZ4_saveDictHC (LZ4_streamHC_t* LZ4_streamHCPtr, char* safeBuffer, int dictS
}
return dictSize;
}
-
-
+
+
/***************************************************
* Deprecated Functions
***************************************************/
@@ -1200,41 +1200,41 @@ int LZ4_compressHC2_withStateHC (void* state, const char* src, char* dst, int sr
int LZ4_compressHC2_limitedOutput_withStateHC (void* state, const char* src, char* dst, int srcSize, int maxDstSize, int cLevel) { return LZ4_compress_HC_extStateHC(state, src, dst, srcSize, maxDstSize, cLevel); }
int LZ4_compressHC_continue (LZ4_streamHC_t* ctx, const char* src, char* dst, int srcSize) { return LZ4_compress_HC_continue (ctx, src, dst, srcSize, LZ4_compressBound(srcSize)); }
int LZ4_compressHC_limitedOutput_continue (LZ4_streamHC_t* ctx, const char* src, char* dst, int srcSize, int maxDstSize) { return LZ4_compress_HC_continue (ctx, src, dst, srcSize, maxDstSize); }
-
-
+
+
/* Deprecated streaming functions */
int LZ4_sizeofStreamStateHC(void) { return LZ4_STREAMHCSIZE; }
-
+
/* state is presumed correctly sized, aka >= sizeof(LZ4_streamHC_t)
* @return : 0 on success, !=0 if error */
int LZ4_resetStreamStateHC(void* state, char* inputBuffer)
-{
+{
LZ4_streamHC_t* const hc4 = LZ4_initStreamHC(state, sizeof(*hc4));
if (hc4 == NULL) return 1; /* init failed */
LZ4HC_init_internal (&hc4->internal_donotuse, (const BYTE*)inputBuffer);
return 0;
}
-
+
void* LZ4_createHC (const char* inputBuffer)
{
LZ4_streamHC_t* const hc4 = LZ4_createStreamHC();
if (hc4 == NULL) return NULL; /* not enough memory */
LZ4HC_init_internal (&hc4->internal_donotuse, (const BYTE*)inputBuffer);
return hc4;
-}
-
+}
+
int LZ4_freeHC (void* LZ4HC_Data)
{
if (!LZ4HC_Data) return 0; /* support free on NULL */
FREEMEM(LZ4HC_Data);
return 0;
}
-
+
int LZ4_compressHC2_continue (void* LZ4HC_Data, const char* src, char* dst, int srcSize, int cLevel)
{
return LZ4HC_compress_generic (&((LZ4_streamHC_t*)LZ4HC_Data)->internal_donotuse, src, dst, &srcSize, 0, cLevel, notLimited);
}
-
+
int LZ4_compressHC2_limitedOutput_continue (void* LZ4HC_Data, const char* src, char* dst, int srcSize, int dstCapacity, int cLevel)
{
return LZ4HC_compress_generic (&((LZ4_streamHC_t*)LZ4HC_Data)->internal_donotuse, src, dst, &srcSize, dstCapacity, cLevel, limitedOutput);