Rizin
unix-like reverse engineering framework and cli tools
lz4hc.h File Reference
#include "lz4.h"

Go to the source code of this file.

Classes

struct  LZ4HC_CCtx_internal
 
union  LZ4_streamHC_u
 

Macros

#define LZ4HC_CLEVEL_MIN   3
 
#define LZ4HC_CLEVEL_DEFAULT   9
 
#define LZ4HC_CLEVEL_OPT_MIN   10
 
#define LZ4HC_CLEVEL_MAX   12
 
#define LZ4HC_DICTIONARY_LOGSIZE   16
 
#define LZ4HC_MAXD   (1<<LZ4HC_DICTIONARY_LOGSIZE)
 
#define LZ4HC_MAXD_MASK   (LZ4HC_MAXD - 1)
 
#define LZ4HC_HASH_LOG   15
 
#define LZ4HC_HASHTABLESIZE   (1 << LZ4HC_HASH_LOG)
 
#define LZ4HC_HASH_MASK   (LZ4HC_HASHTABLESIZE - 1)
 
#define LZ4_STREAMHCSIZE   262200 /* static size, for inter-version compatibility */
 
#define LZ4_STREAMHCSIZE_VOIDP   (LZ4_STREAMHCSIZE / sizeof(void*))
 

Typedefs

typedef union LZ4_streamHC_u LZ4_streamHC_t
 
typedef struct LZ4HC_CCtx_internal LZ4HC_CCtx_internal
 

Functions

LZ4LIB_API int LZ4_compress_HC (const char *src, char *dst, int srcSize, int dstCapacity, int compressionLevel)
 
LZ4LIB_API int LZ4_sizeofStateHC (void)
 
LZ4LIB_API int LZ4_compress_HC_extStateHC (void *stateHC, const char *src, char *dst, int srcSize, int maxDstSize, int compressionLevel)
 
LZ4LIB_API int LZ4_compress_HC_destSize (void *stateHC, const char *src, char *dst, int *srcSizePtr, int targetDstSize, int compressionLevel)
 
LZ4LIB_API LZ4_streamHC_tLZ4_createStreamHC (void)
 
LZ4LIB_API int LZ4_freeStreamHC (LZ4_streamHC_t *streamHCPtr)
 
LZ4LIB_API void LZ4_resetStreamHC_fast (LZ4_streamHC_t *streamHCPtr, int compressionLevel)
 
LZ4LIB_API int LZ4_loadDictHC (LZ4_streamHC_t *streamHCPtr, const char *dictionary, int dictSize)
 
LZ4LIB_API int LZ4_compress_HC_continue (LZ4_streamHC_t *streamHCPtr, const char *src, char *dst, int srcSize, int maxDstSize)
 
LZ4LIB_API int LZ4_compress_HC_continue_destSize (LZ4_streamHC_t *LZ4_streamHCPtr, const char *src, char *dst, int *srcSizePtr, int targetDstSize)
 
LZ4LIB_API int LZ4_saveDictHC (LZ4_streamHC_t *streamHCPtr, char *safeBuffer, int maxDictSize)
 
LZ4LIB_API LZ4_streamHC_tLZ4_initStreamHC (void *buffer, size_t size)
 
 LZ4_DEPRECATED ("use LZ4_compress_HC() instead") LZ4LIB_API int LZ4_compressHC(const char *source
 
 LZ4_DEPRECATED ("use LZ4_compress_HC_extStateHC() instead") LZ4LIB_API int LZ4_compressHC_withStateHC(void *state
 
 LZ4_DEPRECATED ("use LZ4_compress_HC_continue() instead") LZ4LIB_API int LZ4_compressHC_continue(LZ4_streamHC_t *LZ4_streamHCPtr
 
 LZ4_DEPRECATED ("use LZ4_createStreamHC() instead") LZ4LIB_API void *LZ4_createHC(const char *inputBuffer)
 
 LZ4_DEPRECATED ("use LZ4_saveDictHC() instead") LZ4LIB_API char *LZ4_slideInputBufferHC(void *LZ4HC_Data)
 
 LZ4_DEPRECATED ("use LZ4_freeStreamHC() instead") LZ4LIB_API int LZ4_freeHC(void *LZ4HC_Data)
 
 LZ4_DEPRECATED ("use LZ4_initStreamHC() instead") LZ4LIB_API int LZ4_resetStreamStateHC(void *state
 
LZ4LIB_API void LZ4_resetStreamHC (LZ4_streamHC_t *streamHCPtr, int compressionLevel)
 

Variables

char * dest
 
char int inputSize
 
char int int maxOutputSize
 
char int int compressionLevel
 
const char * source
 
char * inputBuffer
 

Macro Definition Documentation

◆ LZ4_STREAMHCSIZE

#define LZ4_STREAMHCSIZE   262200 /* static size, for inter-version compatibility */

Definition at line 223 of file lz4hc.h.

◆ LZ4_STREAMHCSIZE_VOIDP

#define LZ4_STREAMHCSIZE_VOIDP   (LZ4_STREAMHCSIZE / sizeof(void*))

Definition at line 224 of file lz4hc.h.

◆ LZ4HC_CLEVEL_DEFAULT

#define LZ4HC_CLEVEL_DEFAULT   9

Definition at line 48 of file lz4hc.h.

◆ LZ4HC_CLEVEL_MAX

#define LZ4HC_CLEVEL_MAX   12

Definition at line 50 of file lz4hc.h.

◆ LZ4HC_CLEVEL_MIN

#define LZ4HC_CLEVEL_MIN   3

Definition at line 47 of file lz4hc.h.

◆ LZ4HC_CLEVEL_OPT_MIN

#define LZ4HC_CLEVEL_OPT_MIN   10

Definition at line 49 of file lz4hc.h.

◆ LZ4HC_DICTIONARY_LOGSIZE

#define LZ4HC_DICTIONARY_LOGSIZE   16

Definition at line 192 of file lz4hc.h.

◆ LZ4HC_HASH_LOG

#define LZ4HC_HASH_LOG   15

Definition at line 196 of file lz4hc.h.

◆ LZ4HC_HASH_MASK

#define LZ4HC_HASH_MASK   (LZ4HC_HASHTABLESIZE - 1)

Definition at line 198 of file lz4hc.h.

◆ LZ4HC_HASHTABLESIZE

#define LZ4HC_HASHTABLESIZE   (1 << LZ4HC_HASH_LOG)

Definition at line 197 of file lz4hc.h.

◆ LZ4HC_MAXD

#define LZ4HC_MAXD   (1<<LZ4HC_DICTIONARY_LOGSIZE)

Definition at line 193 of file lz4hc.h.

◆ LZ4HC_MAXD_MASK

#define LZ4HC_MAXD_MASK   (LZ4HC_MAXD - 1)

Definition at line 194 of file lz4hc.h.

Typedef Documentation

◆ LZ4_streamHC_t

Definition at line 91 of file lz4hc.h.

◆ LZ4HC_CCtx_internal

Definition at line 176 of file lz4hc.h.

Function Documentation

◆ LZ4_compress_HC()

LZ4LIB_API int LZ4_compress_HC ( const char *  src,
char *  dst,
int  srcSize,
int  dstCapacity,
int  compressionLevel 
)

LZ4_compress_HC() : Compress data from src into dst, using the powerful but slower "HC" algorithm. dst must be already allocated. Compression is guaranteed to succeed if dstCapacity >= LZ4_compressBound(srcSize) (see "lz4.h") Max supported srcSize value is LZ4_MAX_INPUT_SIZE (see "lz4.h") compressionLevel : any value between 1 and LZ4HC_CLEVEL_MAX will work. Values > LZ4HC_CLEVEL_MAX behave the same as LZ4HC_CLEVEL_MAX.

Returns
: the number of bytes written into 'dst' or 0 if compression fails.

Definition at line 954 of file lz4hc.c.

955 {
956 #if defined(LZ4HC_HEAPMODE) && LZ4HC_HEAPMODE==1
957  LZ4_streamHC_t* const statePtr = (LZ4_streamHC_t*)ALLOC(sizeof(LZ4_streamHC_t));
958 #else
960  LZ4_streamHC_t* const statePtr = &state;
961 #endif
962  int const cSize = LZ4_compress_HC_extStateHC(statePtr, src, dst, srcSize, dstCapacity, compressionLevel);
963 #if defined(LZ4HC_HEAPMODE) && LZ4HC_HEAPMODE==1
964  FREEMEM(statePtr);
965 #endif
966  return cSize;
967 }
lzma_index * src
Definition: index.h:567
#define ALLOC(s)
Definition: lz4.c:202
#define FREEMEM(p)
Definition: lz4.c:204
char int srcSize
Definition: lz4.h:697
char * dst
Definition: lz4.h:724
int LZ4_compress_HC_extStateHC(void *state, const char *src, char *dst, int srcSize, int dstCapacity, int compressionLevel)
Definition: lz4hc.c:947
char int int compressionLevel
Definition: lz4hc.h:258
Definition: dis.h:43

References ALLOC, compressionLevel, dst, FREEMEM, LZ4_compress_HC_extStateHC(), src, and srcSize.

Referenced by FUZ_test(), LLVMFuzzerTestOneInput(), local_LZ4_compress_HC(), LZ4_compressBlockNoStreamHC(), LZ4_compressHC(), LZ4_compressHC2(), LZ4_compressHC2_limitedOutput(), LZ4_compressHC_limitedOutput(), LZ4IO_compressFilename_Legacy(), and roundTripTest().

◆ LZ4_compress_HC_continue()

LZ4LIB_API int LZ4_compress_HC_continue ( LZ4_streamHC_t streamHCPtr,
const char *  src,
char *  dst,
int  srcSize,
int  maxDstSize 
)

Definition at line 1138 of file lz4hc.c.

1139 {
1140  if (dstCapacity < LZ4_compressBound(srcSize))
1141  return LZ4_compressHC_continue_generic (LZ4_streamHCPtr, src, dst, &srcSize, dstCapacity, limitedOutput);
1142  else
1143  return LZ4_compressHC_continue_generic (LZ4_streamHCPtr, src, dst, &srcSize, dstCapacity, notLimited);
1144 }
int LZ4_compressBound(int isize)
Definition: lz4.c:674
@ limitedOutput
Definition: lz4.c:302
@ notLimited
Definition: lz4.c:301
static int LZ4_compressHC_continue_generic(LZ4_streamHC_t *LZ4_streamHCPtr, const char *src, char *dst, int *srcSizePtr, int dstCapacity, limitedOutput_directive limit)
Definition: lz4hc.c:1102

References dst, limitedOutput, LZ4_compressBound(), LZ4_compressHC_continue_generic(), notLimited, src, and srcSize.

Referenced by FUZ_test(), FUZ_unitTests(), local_LZ4_compress_HC_continue(), LZ4_compressBlockStreamHC(), LZ4_compressHC_continue(), LZ4_compressHC_limitedOutput_continue(), LZ4F_compressBlockHC(), LZ4F_compressBlockHC_continue(), state_extDictHCRoundTrip(), state_prefixHCRoundTrip(), and test_compress().

◆ LZ4_compress_HC_continue_destSize()

LZ4LIB_API int LZ4_compress_HC_continue_destSize ( LZ4_streamHC_t LZ4_streamHCPtr,
const char *  src,
char *  dst,
int srcSizePtr,
int  targetDstSize 
)

LZ4_compress_HC_continue_destSize() : v1.9.0+ Similar to LZ4_compress_HC_continue(), but will read as much data as possible from src to fit into targetDstSize budget. Result is provided into 2 parts :

Returns
: the number of bytes written into 'dst' (necessarily <= targetDstSize) or 0 if compression fails. srcSizePtr : on success, *srcSizePtr will be updated to indicate how much bytes were read from src. Note that this function may not consume the entire input.

Definition at line 1146 of file lz4hc.c.

1147 {
1148  return LZ4_compressHC_continue_generic(LZ4_streamHCPtr, src, dst, srcSizePtr, targetDestSize, fillOutput);
1149 }
@ fillOutput
Definition: lz4.c:303

References dst, fillOutput, LZ4_compressHC_continue_generic(), and src.

Referenced by FUZ_test().

◆ LZ4_compress_HC_destSize()

LZ4LIB_API int LZ4_compress_HC_destSize ( void *  stateHC,
const char *  src,
char *  dst,
int srcSizePtr,
int  targetDstSize,
int  compressionLevel 
)

LZ4_compress_HC_destSize() : v1.9.0+ Will compress as much data as possible from src to fit into targetDstSize budget. Result is provided in 2 parts :

Returns
: the number of bytes written into 'dst' (necessarily <= targetDstSize) or 0 if compression fails. srcSizePtr : on success, *srcSizePtr is updated to indicate how much bytes were read from src

Definition at line 970 of file lz4hc.c.

971 {
972  LZ4_streamHC_t* const ctx = LZ4_initStreamHC(state, sizeof(*ctx));
973  if (ctx==NULL) return 0; /* init failure */
974  LZ4HC_init_internal(&ctx->internal_donotuse, (const BYTE*) source);
975  LZ4_setCompressionLevel(ctx, cLevel);
976  return LZ4HC_compress_generic(&ctx->internal_donotuse, source, dest, sourceSizePtr, targetDestSize, cLevel, fillOutput);
977 }
#define NULL
Definition: cris-opc.c:27
unsigned char BYTE
Definition: lz4.c:286
const char * source
Definition: lz4.h:699
char * dest
Definition: lz4.h:697
LZ4_streamHC_t * LZ4_initStreamHC(void *buffer, size_t size)
Definition: lz4hc.c:1003
static void LZ4HC_init_internal(LZ4HC_CCtx_internal *hc4, const BYTE *start)
Definition: lz4hc.c:100
static int LZ4HC_compress_generic(LZ4HC_CCtx_internal *const ctx, const char *const src, char *const dst, int *const srcSizePtr, int const dstCapacity, int cLevel, limitedOutput_directive limit)
Definition: lz4hc.c:903
void LZ4_setCompressionLevel(LZ4_streamHC_t *LZ4_streamHCPtr, int compressionLevel)
Definition: lz4hc.c:1041

References dest, fillOutput, LZ4_initStreamHC(), LZ4_setCompressionLevel(), LZ4HC_compress_generic(), LZ4HC_init_internal(), NULL, and source.

Referenced by FUZ_test(), FUZ_unitTests(), and LLVMFuzzerTestOneInput().

◆ LZ4_compress_HC_extStateHC()

LZ4LIB_API int LZ4_compress_HC_extStateHC ( void *  stateHC,
const char *  src,
char *  dst,
int  srcSize,
int  maxDstSize,
int  compressionLevel 
)

Definition at line 947 of file lz4hc.c.

948 {
949  LZ4_streamHC_t* const ctx = LZ4_initStreamHC(state, sizeof(*ctx));
950  if (ctx==NULL) return 0; /* init failure */
952 }
int LZ4_compress_HC_extStateHC_fastReset(void *state, const char *src, char *dst, int srcSize, int dstCapacity, int compressionLevel)
Definition: lz4hc.c:935

References compressionLevel, dst, LZ4_compress_HC_extStateHC_fastReset(), LZ4_initStreamHC(), NULL, src, and srcSize.

Referenced by FUZ_test(), local_LZ4_compress_HC_extStateHC(), LZ4_compress_HC(), LZ4_compressHC2_limitedOutput_withStateHC(), LZ4_compressHC2_withStateHC(), LZ4_compressHC_limitedOutput_withStateHC(), and LZ4_compressHC_withStateHC().

◆ LZ4_createStreamHC()

LZ4LIB_API LZ4_streamHC_t* LZ4_createStreamHC ( void  )

LZ4_createStreamHC() and LZ4_freeStreamHC() : These functions create and release memory for LZ4 HC streaming state. Newly created states are automatically initialized. A same state can be used multiple times consecutively, starting with LZ4_resetStreamHC_fast() to start a new stream of blocks.

Definition at line 985 of file lz4hc.c.

986 {
987  LZ4_streamHC_t* const state =
989  if (state == NULL) return NULL;
991  return state;
992 }
#define ALLOC_AND_ZERO(s)
Definition: lz4.c:203
#define LZ4HC_CLEVEL_DEFAULT
Definition: lz4hc.h:48

References ALLOC_AND_ZERO, LZ4_setCompressionLevel(), LZ4HC_CLEVEL_DEFAULT, and NULL.

Referenced by FUZ_test(), FUZ_unitTests(), LZ4_compressInitStreamHC(), LZ4_createHC(), LZ4F_compressBegin_usingCDict(), LZ4F_createCDict(), state_attachDictHCRoundTrip(), and state_create().

◆ LZ4_DEPRECATED() [1/7]

LZ4_DEPRECATED ( "use LZ4_compress_HC() instead"  ) const

◆ LZ4_DEPRECATED() [2/7]

LZ4_DEPRECATED ( "use LZ4_compress_HC_continue() instead"  )

◆ LZ4_DEPRECATED() [3/7]

LZ4_DEPRECATED ( "use LZ4_compress_HC_extStateHC() instead"  )

◆ LZ4_DEPRECATED() [4/7]

LZ4_DEPRECATED ( "use LZ4_createStreamHC() instead"  ) const

◆ LZ4_DEPRECATED() [5/7]

LZ4_DEPRECATED ( "use LZ4_freeStreamHC() instead"  )

◆ LZ4_DEPRECATED() [6/7]

LZ4_DEPRECATED ( "use LZ4_initStreamHC() instead"  )

◆ LZ4_DEPRECATED() [7/7]

LZ4_DEPRECATED ( "use LZ4_saveDictHC() instead"  )

◆ LZ4_freeStreamHC()

LZ4LIB_API int LZ4_freeStreamHC ( LZ4_streamHC_t streamHCPtr)

Definition at line 994 of file lz4hc.c.

995 {
996  DEBUGLOG(4, "LZ4_freeStreamHC(%p)", LZ4_streamHCPtr);
997  if (!LZ4_streamHCPtr) return 0; /* support free on NULL */
998  FREEMEM(LZ4_streamHCPtr);
999  return 0;
1000 }
#define DEBUGLOG(l,...)
Definition: lz4.c:261

References DEBUGLOG, and FREEMEM.

Referenced by FUZ_test(), FUZ_unitTests(), LZ4_compressCleanupStreamHC(), LZ4F_freeCDict(), state_attachDictHCRoundTrip(), and state_free().

◆ LZ4_initStreamHC()

LZ4LIB_API LZ4_streamHC_t* LZ4_initStreamHC ( void *  buffer,
size_t  size 
)

Definition at line 1003 of file lz4hc.c.

1004 {
1005  LZ4_streamHC_t* const LZ4_streamHCPtr = (LZ4_streamHC_t*)buffer;
1006  /* if compilation fails here, LZ4_STREAMHCSIZE must be increased */
1008  DEBUGLOG(4, "LZ4_initStreamHC(%p, %u)", buffer, (unsigned)size);
1009  /* check conditions */
1010  if (buffer == NULL) return NULL;
1011  if (size < sizeof(LZ4_streamHC_t)) return NULL;
1013  /* init */
1014  { LZ4HC_CCtx_internal* const hcstate = &(LZ4_streamHCPtr->internal_donotuse);
1015  MEM_INIT(hcstate, 0, sizeof(*hcstate)); }
1017  return LZ4_streamHCPtr;
1018 }
voidpf void uLong size
Definition: ioapi.h:138
#define LZ4_STATIC_ASSERT(c)
Definition: lz4.c:249
#define MEM_INIT(p, v, s)
Definition: lz4.c:208
static int LZ4_isAligned(const void *ptr, size_t alignment)
Definition: lz4.c:264
static size_t LZ4_streamHC_t_alignment(void)
Definition: lz4hc.c:923
#define LZ4_STREAMHCSIZE
Definition: lz4hc.h:223
Definition: buffer.h:15
LZ4HC_CCtx_internal internal_donotuse
Definition: lz4hc.h:227

References DEBUGLOG, LZ4_streamHC_u::internal_donotuse, LZ4_isAligned(), LZ4_setCompressionLevel(), LZ4_STATIC_ASSERT, LZ4_streamHC_t_alignment(), LZ4_STREAMHCSIZE, LZ4HC_CLEVEL_DEFAULT, MEM_INIT, and NULL.

Referenced by FUZ_unitTests(), local_LZ4_resetStreamHC(), LZ4_compress_HC_destSize(), LZ4_compress_HC_extStateHC(), LZ4_loadDictHC(), LZ4_resetStreamHC(), LZ4_resetStreamHC_fast(), LZ4_resetStreamStateHC(), and LZ4F_compressBegin_usingCDict().

◆ LZ4_loadDictHC()

LZ4LIB_API int LZ4_loadDictHC ( LZ4_streamHC_t streamHCPtr,
const char *  dictionary,
int  dictSize 
)

Definition at line 1056 of file lz4hc.c.

1058 {
1059  LZ4HC_CCtx_internal* const ctxPtr = &LZ4_streamHCPtr->internal_donotuse;
1060  DEBUGLOG(4, "LZ4_loadDictHC(ctx:%p, dict:%p, dictSize:%d)", LZ4_streamHCPtr, dictionary, dictSize);
1061  assert(LZ4_streamHCPtr != NULL);
1062  if (dictSize > 64 KB) {
1063  dictionary += (size_t)dictSize - 64 KB;
1064  dictSize = 64 KB;
1065  }
1066  /* need a full initialization, there are bad side-effects when using resetFast() */
1067  { int const cLevel = ctxPtr->compressionLevel;
1068  LZ4_initStreamHC(LZ4_streamHCPtr, sizeof(*LZ4_streamHCPtr));
1069  LZ4_setCompressionLevel(LZ4_streamHCPtr, cLevel);
1070  }
1071  LZ4HC_init_internal (ctxPtr, (const BYTE*)dictionary);
1072  ctxPtr->end = (const BYTE*)dictionary + dictSize;
1073  if (dictSize >= 4) LZ4HC_Insert (ctxPtr, ctxPtr->end-3);
1074  return dictSize;
1075 }
LZ4_FORCE_INLINE void LZ4HC_Insert(LZ4HC_CCtx_internal *hc4, const BYTE *ip)
Definition: lz4hc.c:118
assert(limit<=UINT32_MAX/2)
int size_t
Definition: sftypes.h:40
short compressionLevel
Definition: lz4hc.h:212
const LZ4_byte * end
Definition: lz4hc.h:206
#define KB
Definition: unum.c:91

References assert(), LZ4HC_CCtx_internal::compressionLevel, DEBUGLOG, LZ4HC_CCtx_internal::end, LZ4_streamHC_u::internal_donotuse, KB, LZ4_initStreamHC(), LZ4_setCompressionLevel(), LZ4HC_init_internal(), LZ4HC_Insert(), and NULL.

Referenced by fullSpeedBench(), FUZ_test(), FUZ_unitTests(), LZ4_compressHC_continue_generic(), LZ4_compressInitStreamHC(), LZ4F_createCDict(), state_attachDictHCRoundTrip(), and state_loadDictHCRoundTrip().

◆ LZ4_resetStreamHC()

LZ4LIB_API void LZ4_resetStreamHC ( LZ4_streamHC_t streamHCPtr,
int  compressionLevel 
)

Definition at line 1021 of file lz4hc.c.

1022 {
1023  LZ4_initStreamHC(LZ4_streamHCPtr, sizeof(*LZ4_streamHCPtr));
1024  LZ4_setCompressionLevel(LZ4_streamHCPtr, compressionLevel);
1025 }

References compressionLevel, LZ4_initStreamHC(), and LZ4_setCompressionLevel().

Referenced by FUZ_unitTests().

◆ LZ4_resetStreamHC_fast()

LZ4LIB_API void LZ4_resetStreamHC_fast ( LZ4_streamHC_t streamHCPtr,
int  compressionLevel 
)

Definition at line 1027 of file lz4hc.c.

1028 {
1029  DEBUGLOG(4, "LZ4_resetStreamHC_fast(%p, %d)", LZ4_streamHCPtr, compressionLevel);
1030  if (LZ4_streamHCPtr->internal_donotuse.dirty) {
1031  LZ4_initStreamHC(LZ4_streamHCPtr, sizeof(*LZ4_streamHCPtr));
1032  } else {
1033  /* preserve end - base : can trigger clearTable's threshold */
1034  LZ4_streamHCPtr->internal_donotuse.end -= (uptrval)LZ4_streamHCPtr->internal_donotuse.base;
1035  LZ4_streamHCPtr->internal_donotuse.base = NULL;
1036  LZ4_streamHCPtr->internal_donotuse.dictCtx = NULL;
1037  }
1038  LZ4_setCompressionLevel(LZ4_streamHCPtr, compressionLevel);
1039 }
size_t uptrval
Definition: lz4.c:291

References LZ4HC_CCtx_internal::base, compressionLevel, DEBUGLOG, LZ4HC_CCtx_internal::dictCtx, LZ4HC_CCtx_internal::dirty, LZ4HC_CCtx_internal::end, LZ4_streamHC_u::internal_donotuse, LZ4_initStreamHC(), LZ4_setCompressionLevel(), and NULL.

Referenced by FUZ_test(), FUZ_unitTests(), LZ4_compress_HC_extStateHC_fastReset(), LZ4_compressResetStreamHC(), LZ4_slideInputBufferHC(), LZ4F_initStream(), and state_reset().

◆ LZ4_saveDictHC()

LZ4LIB_API int LZ4_saveDictHC ( LZ4_streamHC_t streamHCPtr,
char *  safeBuffer,
int  maxDictSize 
)

Definition at line 1158 of file lz4hc.c.

1159 {
1160  LZ4HC_CCtx_internal* const streamPtr = &LZ4_streamHCPtr->internal_donotuse;
1161  int const prefixSize = (int)(streamPtr->end - (streamPtr->base + streamPtr->dictLimit));
1162  DEBUGLOG(5, "LZ4_saveDictHC(%p, %p, %d)", LZ4_streamHCPtr, safeBuffer, dictSize);
1163  assert(prefixSize >= 0);
1164  if (dictSize > 64 KB) dictSize = 64 KB;
1165  if (dictSize < 4) dictSize = 0;
1166  if (dictSize > prefixSize) dictSize = prefixSize;
1167  if (safeBuffer == NULL) assert(dictSize == 0);
1168  if (dictSize > 0)
1169  memmove(safeBuffer, streamPtr->end - dictSize, dictSize);
1170  { U32 const endIndex = (U32)(streamPtr->end - streamPtr->base);
1171  streamPtr->end = (const BYTE*)safeBuffer + dictSize;
1172  streamPtr->base = streamPtr->end - endIndex;
1173  streamPtr->dictLimit = endIndex - (U32)dictSize;
1174  streamPtr->lowLimit = endIndex - (U32)dictSize;
1175  if (streamPtr->nextToUpdate < streamPtr->dictLimit)
1176  streamPtr->nextToUpdate = streamPtr->dictLimit;
1177  }
1178  return dictSize;
1179 }
unsigned int U32
Definition: lz4.c:288
#define U32(val)
static int
Definition: sfsocketcall.h:114
LZ4_u32 dictLimit
Definition: lz4hc.h:209
LZ4_u32 nextToUpdate
Definition: lz4hc.h:211
const LZ4_byte * base
Definition: lz4hc.h:207
LZ4_u32 lowLimit
Definition: lz4hc.h:210

References assert(), LZ4HC_CCtx_internal::base, DEBUGLOG, LZ4HC_CCtx_internal::dictLimit, LZ4HC_CCtx_internal::end, int, LZ4_streamHC_u::internal_donotuse, KB, LZ4HC_CCtx_internal::lowLimit, LZ4HC_CCtx_internal::nextToUpdate, NULL, and U32.

Referenced by FUZ_unitTests(), local_LZ4_saveDictHC(), and LZ4F_localSaveDict().

◆ LZ4_sizeofStateHC()

LZ4LIB_API int LZ4_sizeofStateHC ( void  )

LZ4_compress_HC_extStateHC() : Same as LZ4_compress_HC(), but using an externally allocated memory segment for state. state size is provided by LZ4_sizeofStateHC(). Memory segment must be aligned on 8-bytes boundaries (which a normal malloc() should do properly).

Definition at line 921 of file lz4hc.c.

921 { return (int)sizeof(LZ4_streamHC_t); }
union LZ4_streamHC_u LZ4_streamHC_t
Definition: lz4hc.h:101

Referenced by FUZ_test(), and LLVMFuzzerTestOneInput().

Variable Documentation

◆ compressionLevel

◆ dest

const char char* dest

Definition at line 256 of file lz4hc.h.

◆ inputBuffer

char* inputBuffer

Definition at line 281 of file lz4hc.h.

◆ inputSize

const char char int inputSize

Definition at line 256 of file lz4hc.h.

◆ maxOutputSize

const char char int int maxOutputSize

Definition at line 257 of file lz4hc.h.

◆ source

const char* source

Definition at line 260 of file lz4hc.h.