Leviathan  0.8.0.0
Leviathan game engine
lz4.c File Reference
#include <stdlib.h>
#include <string.h>
#include "lz4.h"

Go to the source code of this file.

Classes

struct  _PACKED
 
struct  _PACKED
 
struct  _PACKED
 
struct  _PACKED
 
struct  LZ4_Data_Structure
 

Macros

#define MEMORY_USAGE   14
 
#define HEAPMODE   0
 
#define LZ4_ARCH64   0
 
#define restrict
 
#define FORCE_INLINE   static inline
 
#define lz4_bswap16(x)   ((unsigned short int) ((((x) >> 8) & 0xffu) | (((x) & 0xffu) << 8)))
 
#define GCC_VERSION   (__GNUC__ * 100 + __GNUC_MINOR__)
 
#define expect(expr, value)   (expr)
 
#define likely(expr)   expect((expr) != 0, 1)
 
#define unlikely(expr)   expect((expr) != 0, 0)
 
#define ALLOCATOR(n, s)   calloc(n,s)
 
#define FREEMEM   free
 
#define MEM_INIT   memset
 
#define _PACKED
 
#define A16(x)   (((U16_S *)(x))->v)
 
#define A32(x)   (((U32_S *)(x))->v)
 
#define A64(x)   (((U64_S *)(x))->v)
 
#define AARCH(x)   (((size_t_S *)(x))->v)
 
#define LZ4_HASHLOG   (MEMORY_USAGE-2)
 
#define HASHTABLESIZE   (1 << MEMORY_USAGE)
 
#define HASHNBCELLS4   (1 << LZ4_HASHLOG)
 
#define MINMATCH   4
 
#define COPYLENGTH   8
 
#define LASTLITERALS   5
 
#define MFLIMIT   (COPYLENGTH+MINMATCH)
 
#define LZ4_64KLIMIT   ((1<<16) + (MFLIMIT-1))
 
#define SKIPSTRENGTH   6
 
#define MAXD_LOG   16
 
#define MAX_DISTANCE   ((1 << MAXD_LOG) - 1)
 
#define ML_BITS   4
 
#define ML_MASK   ((1U<<ML_BITS)-1)
 
#define RUN_BITS   (8-ML_BITS)
 
#define RUN_MASK   ((1U<<RUN_BITS)-1)
 
#define KB   *(1U<<10)
 
#define MB   *(1U<<20)
 
#define GB   *(1U<<30)
 
#define STEPSIZE   sizeof(size_t)
 
#define LZ4_COPYSTEP(d, s)   { AARCH(d) = AARCH(s); d+=STEPSIZE; s+=STEPSIZE; }
 
#define LZ4_COPY8(d, s)   { LZ4_COPYSTEP(d,s); if (STEPSIZE<8) LZ4_COPYSTEP(d,s); }
 
#define LZ4_SECURECOPY(d, s, e)   { if ((STEPSIZE==4)||(d<e)) LZ4_WILDCOPY(d,s,e); }
 
#define HTYPE   const BYTE*
 
#define INITBASE(base)   const int base = 0
 
#define LZ4_READ_LITTLEENDIAN_16(d, s, p)   { d = (s) - A16(p); }
 
#define LZ4_WRITE_LITTLEENDIAN_16(p, v)   { A16(p) = v; p+=2; }
 
#define LZ4_WILDCOPY(d, s, e)   { do { LZ4_COPY8(d,s) } while (d<e); }
 

Typedefs

typedef unsigned char BYTE
 
typedef unsigned short U16
 
typedef unsigned int U32
 
typedef signed int S32
 
typedef unsigned long long U64
 

Enumerations

enum  limitedOutput_directive { notLimited = 0, limited = 1, noLimit = 0, limitedOutput = 1 }
 
enum  tableType_t { byPtr, byU32, byU16 }
 
enum  prefix64k_directive { noPrefix = 0, withPrefix = 1 }
 
enum  endCondition_directive { endOnOutputSize = 0, endOnInputSize = 1 }
 
enum  earlyEnd_directive { full = 0, partial = 1 }
 

Functions

FORCE_INLINE int LZ4_NbCommonBytes (register U32 val)
 
FORCE_INLINE int LZ4_hashSequence (U32 sequence, tableType_t tableType)
 
FORCE_INLINE int LZ4_hashPosition (const BYTE *p, tableType_t tableType)
 
FORCE_INLINE void LZ4_putPositionOnHash (const BYTE *p, U32 h, void *tableBase, tableType_t tableType, const BYTE *srcBase)
 
FORCE_INLINE void LZ4_putPosition (const BYTE *p, void *tableBase, tableType_t tableType, const BYTE *srcBase)
 
FORCE_INLINE const BYTELZ4_getPositionOnHash (U32 h, void *tableBase, tableType_t tableType, const BYTE *srcBase)
 
FORCE_INLINE const BYTELZ4_getPosition (const BYTE *p, void *tableBase, tableType_t tableType, const BYTE *srcBase)
 
FORCE_INLINE int LZ4_compress_generic (void *ctx, const char *source, char *dest, int inputSize, int maxOutputSize, limitedOutput_directive limitedOutput, tableType_t tableType, prefix64k_directive prefix)
 
int LZ4_compress (const char *source, char *dest, int inputSize)
 
int LZ4_compress_limitedOutput (const char *source, char *dest, int inputSize, int maxOutputSize)
 
int LZ4_sizeofState ()
 
int LZ4_compress_withState (void *state, const char *source, char *dest, int inputSize)
 
int LZ4_compress_limitedOutput_withState (void *state, const char *source, char *dest, int inputSize, int maxOutputSize)
 
int LZ4_sizeofStreamState ()
 
FORCE_INLINE void LZ4_init (LZ4_Data_Structure *lz4ds, const BYTE *base)
 
int LZ4_resetStreamState (void *state, const char *inputBuffer)
 
void * LZ4_create (const char *inputBuffer)
 
int LZ4_free (void *LZ4_Data)
 
char * LZ4_slideInputBuffer (void *LZ4_Data)
 
int LZ4_compress_continue (void *LZ4_Data, const char *source, char *dest, int inputSize)
 
int LZ4_compress_limitedOutput_continue (void *LZ4_Data, const char *source, char *dest, int inputSize, int maxOutputSize)
 
FORCE_INLINE int LZ4_decompress_generic (const char *source, char *dest, int inputSize, int outputSize, int endOnInput, int prefix64k, int partialDecoding, int targetOutputSize)
 
int LZ4_decompress_safe (const char *source, char *dest, int inputSize, int maxOutputSize)
 
int LZ4_decompress_safe_withPrefix64k (const char *source, char *dest, int inputSize, int maxOutputSize)
 
int LZ4_decompress_safe_partial (const char *source, char *dest, int inputSize, int targetOutputSize, int maxOutputSize)
 
int LZ4_decompress_fast_withPrefix64k (const char *source, char *dest, int outputSize)
 
int LZ4_decompress_fast (const char *source, char *dest, int outputSize)
 

Variables

const int LZ4_minLength = (MFLIMIT+1)
 

Macro Definition Documentation

◆ _PACKED

#define _PACKED

Definition at line 183 of file lz4.c.

◆ A16

#define A16 (   x)    (((U16_S *)(x))->v)

Definition at line 207 of file lz4.c.

◆ A32

#define A32 (   x)    (((U32_S *)(x))->v)

Definition at line 208 of file lz4.c.

◆ A64

#define A64 (   x)    (((U64_S *)(x))->v)

Definition at line 209 of file lz4.c.

◆ AARCH

#define AARCH (   x)    (((size_t_S *)(x))->v)

Definition at line 210 of file lz4.c.

◆ ALLOCATOR

#define ALLOCATOR (   n,
 
)    calloc(n,s)

Definition at line 150 of file lz4.c.

◆ COPYLENGTH

#define COPYLENGTH   8

Definition at line 222 of file lz4.c.

◆ expect

#define expect (   expr,
  value 
)    (expr)

Definition at line 139 of file lz4.c.

◆ FORCE_INLINE

#define FORCE_INLINE   static inline

Definition at line 124 of file lz4.c.

◆ FREEMEM

#define FREEMEM   free

Definition at line 151 of file lz4.c.

◆ GB

#define GB   *(1U<<30)

Definition at line 240 of file lz4.c.

◆ GCC_VERSION

#define GCC_VERSION   (__GNUC__ * 100 + __GNUC_MINOR__)

Definition at line 134 of file lz4.c.

◆ HASHNBCELLS4

#define HASHNBCELLS4   (1 << LZ4_HASHLOG)

Definition at line 218 of file lz4.c.

◆ HASHTABLESIZE

#define HASHTABLESIZE   (1 << MEMORY_USAGE)

Definition at line 217 of file lz4.c.

◆ HEAPMODE

#define HEAPMODE   0

Definition at line 47 of file lz4.c.

◆ HTYPE

#define HTYPE   const BYTE*

Definition at line 275 of file lz4.c.

◆ INITBASE

#define INITBASE (   base)    const int base = 0

Definition at line 276 of file lz4.c.

◆ KB

#define KB   *(1U<<10)

Definition at line 238 of file lz4.c.

◆ LASTLITERALS

#define LASTLITERALS   5

Definition at line 223 of file lz4.c.

◆ likely

#define likely (   expr)    expect((expr) != 0, 1)

Definition at line 142 of file lz4.c.

◆ LZ4_64KLIMIT

#define LZ4_64KLIMIT   ((1<<16) + (MFLIMIT-1))

Definition at line 227 of file lz4.c.

◆ LZ4_ARCH64

#define LZ4_ARCH64   0

Definition at line 60 of file lz4.c.

◆ lz4_bswap16

#define lz4_bswap16 (   x)    ((unsigned short int) ((((x) >> 8) & 0xffu) | (((x) & 0xffu) << 8)))

Definition at line 131 of file lz4.c.

◆ LZ4_COPY8

#define LZ4_COPY8 (   d,
 
)    { LZ4_COPYSTEP(d,s); if (STEPSIZE<8) LZ4_COPYSTEP(d,s); }

Definition at line 268 of file lz4.c.

◆ LZ4_COPYSTEP

#define LZ4_COPYSTEP (   d,
 
)    { AARCH(d) = AARCH(s); d+=STEPSIZE; s+=STEPSIZE; }

Definition at line 267 of file lz4.c.

◆ LZ4_HASHLOG

#define LZ4_HASHLOG   (MEMORY_USAGE-2)

Definition at line 216 of file lz4.c.

◆ LZ4_READ_LITTLEENDIAN_16

#define LZ4_READ_LITTLEENDIAN_16 (   d,
  s,
 
)    { d = (s) - A16(p); }

Definition at line 283 of file lz4.c.

◆ LZ4_SECURECOPY

#define LZ4_SECURECOPY (   d,
  s,
 
)    { if ((STEPSIZE==4)||(d<e)) LZ4_WILDCOPY(d,s,e); }

Definition at line 269 of file lz4.c.

◆ LZ4_WILDCOPY

#define LZ4_WILDCOPY (   d,
  s,
 
)    { do { LZ4_COPY8(d,s) } while (d<e); }

Definition at line 291 of file lz4.c.

◆ LZ4_WRITE_LITTLEENDIAN_16

#define LZ4_WRITE_LITTLEENDIAN_16 (   p,
 
)    { A16(p) = v; p+=2; }

Definition at line 284 of file lz4.c.

◆ MAX_DISTANCE

#define MAX_DISTANCE   ((1 << MAXD_LOG) - 1)

Definition at line 231 of file lz4.c.

◆ MAXD_LOG

#define MAXD_LOG   16

Definition at line 230 of file lz4.c.

◆ MB

#define MB   *(1U<<20)

Definition at line 239 of file lz4.c.

◆ MEM_INIT

#define MEM_INIT   memset

Definition at line 153 of file lz4.c.

◆ MEMORY_USAGE

#define MEMORY_USAGE   14

Definition at line 42 of file lz4.c.

◆ MFLIMIT

#define MFLIMIT   (COPYLENGTH+MINMATCH)

Definition at line 224 of file lz4.c.

◆ MINMATCH

#define MINMATCH   4

Definition at line 220 of file lz4.c.

◆ ML_BITS

#define ML_BITS   4

Definition at line 233 of file lz4.c.

◆ ML_MASK

#define ML_MASK   ((1U<<ML_BITS)-1)

Definition at line 234 of file lz4.c.

◆ restrict

#define restrict

Definition at line 106 of file lz4.c.

◆ RUN_BITS

#define RUN_BITS   (8-ML_BITS)

Definition at line 235 of file lz4.c.

◆ RUN_MASK

#define RUN_MASK   ((1U<<RUN_BITS)-1)

Definition at line 236 of file lz4.c.

◆ SKIPSTRENGTH

#define SKIPSTRENGTH   6

Definition at line 228 of file lz4.c.

◆ STEPSIZE

#define STEPSIZE   sizeof(size_t)

Definition at line 266 of file lz4.c.

◆ unlikely

#define unlikely (   expr)    expect((expr) != 0, 0)

Definition at line 143 of file lz4.c.

Typedef Documentation

◆ BYTE

typedef unsigned char BYTE

Definition at line 173 of file lz4.c.

◆ S32

typedef signed int S32

Definition at line 176 of file lz4.c.

◆ U16

typedef unsigned short U16

Definition at line 174 of file lz4.c.

◆ U32

typedef unsigned int U32

Definition at line 175 of file lz4.c.

◆ U64

typedef unsigned long long U64

Definition at line 177 of file lz4.c.

Enumeration Type Documentation

◆ earlyEnd_directive

Enumerator
full 
partial 

Definition at line 260 of file lz4.c.

260 { full = 0, partial = 1 } earlyEnd_directive;
Definition: lz4.c:260
Definition: lz4.c:260
earlyEnd_directive
Definition: lz4.c:260

◆ endCondition_directive

Enumerator
endOnOutputSize 
endOnInputSize 

Definition at line 259 of file lz4.c.

◆ limitedOutput_directive

Enumerator
notLimited 
limited 
noLimit 
limitedOutput 

Definition at line 254 of file lz4.c.

Definition: lz4.c:254
limitedOutput_directive
Definition: lz4.c:254

◆ prefix64k_directive

Enumerator
noPrefix 
withPrefix 

Definition at line 257 of file lz4.c.

prefix64k_directive
Definition: lz4.c:257
Definition: lz4.c:257

◆ tableType_t

Enumerator
byPtr 
byU32 
byU16 

Definition at line 255 of file lz4.c.

Definition: lz4.c:255
Definition: lz4.c:255
tableType_t
Definition: lz4.c:255
Definition: lz4.c:255

Function Documentation

◆ LZ4_compress()

int LZ4_compress ( const char *  source,
char *  dest,
int  inputSize 
)

Definition at line 549 of file lz4.c.

550 {
551 #if (HEAPMODE)
552  void* ctx = ALLOCATOR(HASHNBCELLS4, 4); // Aligned on 4-bytes boundaries
553 #else
554  U32 ctx[1U<<(MEMORY_USAGE-2)] = {0}; // Ensure data is aligned on 4-bytes boundaries
555 #endif
556  int result;
557 
558  if (inputSize < (int)LZ4_64KLIMIT)
559  result = LZ4_compress_generic((void*)ctx, source, dest, inputSize, 0, notLimited, byU16, noPrefix);
560  else
561  result = LZ4_compress_generic((void*)ctx, source, dest, inputSize, 0, notLimited, (sizeof(void*)==8) ? byU32 : byPtr, noPrefix);
562 
563 #if (HEAPMODE)
564  FREEMEM(ctx);
565 #endif
566  return result;
567 }
#define HASHNBCELLS4
Definition: lz4.c:218
unsigned int U32
Definition: lz4.c:175
#define FREEMEM
Definition: lz4.c:151
Definition: lz4.c:255
#define ALLOCATOR(n, s)
Definition: lz4.c:150
#define MEMORY_USAGE
Definition: lz4.c:42
Definition: lz4.c:255
FORCE_INLINE int LZ4_compress_generic(void *ctx, const char *source, char *dest, int inputSize, int maxOutputSize, limitedOutput_directive limitedOutput, tableType_t tableType, prefix64k_directive prefix)
Definition: lz4.c:406
#define LZ4_64KLIMIT
Definition: lz4.c:227
Definition: lz4.c:257
Definition: lz4.c:255

◆ LZ4_compress_continue()

int LZ4_compress_continue ( void *  LZ4_Data,
const char *  source,
char *  dest,
int  inputSize 
)

Definition at line 691 of file lz4.c.

692 {
693  return LZ4_compress_generic(LZ4_Data, source, dest, inputSize, 0, notLimited, byU32, withPrefix);
694 }
Definition: lz4.c:255
FORCE_INLINE int LZ4_compress_generic(void *ctx, const char *source, char *dest, int inputSize, int maxOutputSize, limitedOutput_directive limitedOutput, tableType_t tableType, prefix64k_directive prefix)
Definition: lz4.c:406

◆ LZ4_compress_generic()

FORCE_INLINE int LZ4_compress_generic ( void *  ctx,
const char *  source,
char *  dest,
int  inputSize,
int  maxOutputSize,
limitedOutput_directive  limitedOutput,
tableType_t  tableType,
prefix64k_directive  prefix 
)

Definition at line 406 of file lz4.c.

416 {
417  const BYTE* ip = (const BYTE*) source;
418  const BYTE* const base = (prefix==withPrefix) ? ((LZ4_Data_Structure*)ctx)->base : (const BYTE*) source;
419  const BYTE* const lowLimit = ((prefix==withPrefix) ? ((LZ4_Data_Structure*)ctx)->bufferStart : (const BYTE*)source);
420  const BYTE* anchor = (const BYTE*) source;
421  const BYTE* const iend = ip + inputSize;
422  const BYTE* const mflimit = iend - MFLIMIT;
423  const BYTE* const matchlimit = iend - LASTLITERALS;
424 
425  BYTE* op = (BYTE*) dest;
426  BYTE* const oend = op + maxOutputSize;
427 
428  int length;
429  const int skipStrength = SKIPSTRENGTH;
430  U32 forwardH;
431 
432  // Init conditions
433  if ((U32)inputSize > (U32)LZ4_MAX_INPUT_SIZE) return 0; // Unsupported input size, too large (or negative)
434  if ((prefix==withPrefix) && (ip != ((LZ4_Data_Structure*)ctx)->nextBlock)) return 0; // must continue from end of previous block
435  if (prefix==withPrefix) ((LZ4_Data_Structure*)ctx)->nextBlock=iend; // do it now, due to potential early exit
436  if ((tableType == byU16) && (inputSize>=LZ4_64KLIMIT)) return 0; // Size too large (not within 64K limit)
437  if (inputSize<LZ4_minLength) goto _last_literals; // Input too small, no compression (all literals)
438 
439  // First Byte
440  LZ4_putPosition(ip, ctx, tableType, base);
441  ip++; forwardH = LZ4_hashPosition(ip, tableType);
442 
443  // Main Loop
444  for ( ; ; )
445  {
446  int findMatchAttempts = (1U << skipStrength) + 3;
447  const BYTE* forwardIp = ip;
448  const BYTE* ref;
449  BYTE* token;
450 
451  // Find a match
452  do {
453  U32 h = forwardH;
454  int step = findMatchAttempts++ >> skipStrength;
455  ip = forwardIp;
456  forwardIp = ip + step;
457 
458  if unlikely(forwardIp > mflimit) { goto _last_literals; }
459 
460  forwardH = LZ4_hashPosition(forwardIp, tableType);
461  ref = LZ4_getPositionOnHash(h, ctx, tableType, base);
462  LZ4_putPositionOnHash(ip, h, ctx, tableType, base);
463 
464  } while ((ref + MAX_DISTANCE < ip) || (A32(ref) != A32(ip)));
465 
466  // Catch up
467  while ((ip>anchor) && (ref > lowLimit) && unlikely(ip[-1]==ref[-1])) { ip--; ref--; }
468 
469  // Encode Literal length
470  length = (int)(ip - anchor);
471  token = op++;
472  if ((limitedOutput) && unlikely(op + length + (2 + 1 + LASTLITERALS) + (length/255) > oend)) return 0; // Check output limit
473  if (length>=(int)RUN_MASK)
474  {
475  int len = length-RUN_MASK;
476  *token=(RUN_MASK<<ML_BITS);
477  for(; len >= 255 ; len-=255) *op++ = 255;
478  *op++ = (BYTE)len;
479  }
480  else *token = (BYTE)(length<<ML_BITS);
481 
482  // Copy Literals
483  { BYTE* end=(op)+(length); LZ4_WILDCOPY(op,anchor,end); op=end; }
484 
485 _next_match:
486  // Encode Offset
487  LZ4_WRITE_LITTLEENDIAN_16(op,(U16)(ip-ref));
488 
489  // Start Counting
490  ip+=MINMATCH; ref+=MINMATCH; // MinMatch already verified
491  anchor = ip;
492  while likely(ip<matchlimit-(STEPSIZE-1))
493  {
494  size_t diff = AARCH(ref) ^ AARCH(ip);
495  if (!diff) { ip+=STEPSIZE; ref+=STEPSIZE; continue; }
496  ip += LZ4_NbCommonBytes(diff);
497  goto _endCount;
498  }
499  if (LZ4_ARCH64) if ((ip<(matchlimit-3)) && (A32(ref) == A32(ip))) { ip+=4; ref+=4; }
500  if ((ip<(matchlimit-1)) && (A16(ref) == A16(ip))) { ip+=2; ref+=2; }
501  if ((ip<matchlimit) && (*ref == *ip)) ip++;
502 _endCount:
503 
504  // Encode MatchLength
505  length = (int)(ip - anchor);
506  if ((limitedOutput) && unlikely(op + (1 + LASTLITERALS) + (length>>8) > oend)) return 0; // Check output limit
507  if (length>=(int)ML_MASK)
508  {
509  *token += ML_MASK;
510  length -= ML_MASK;
511  for (; length > 509 ; length-=510) { *op++ = 255; *op++ = 255; }
512  if (length >= 255) { length-=255; *op++ = 255; }
513  *op++ = (BYTE)length;
514  }
515  else *token += (BYTE)(length);
516 
517  // Test end of chunk
518  if (ip > mflimit) { anchor = ip; break; }
519 
520  // Fill table
521  LZ4_putPosition(ip-2, ctx, tableType, base);
522 
523  // Test next position
524  ref = LZ4_getPosition(ip, ctx, tableType, base);
525  LZ4_putPosition(ip, ctx, tableType, base);
526  if ((ref + MAX_DISTANCE >= ip) && (A32(ref) == A32(ip))) { token = op++; *token=0; goto _next_match; }
527 
528  // Prepare next loop
529  anchor = ip++;
530  forwardH = LZ4_hashPosition(ip, tableType);
531  }
532 
533 _last_literals:
534  // Encode Last Literals
535  {
536  int lastRun = (int)(iend - anchor);
537  if ((limitedOutput) && (((char*)op - dest) + lastRun + 1 + ((lastRun+255-RUN_MASK)/255) > (U32)maxOutputSize)) return 0; // Check output limit
538  if (lastRun>=(int)RUN_MASK) { *op++=(RUN_MASK<<ML_BITS); lastRun-=RUN_MASK; for(; lastRun >= 255 ; lastRun-=255) *op++ = 255; *op++ = (BYTE) lastRun; }
539  else *op++ = (BYTE)(lastRun<<ML_BITS);
540  memcpy(op, anchor, iend - anchor);
541  op += iend-anchor;
542  }
543 
544  // End
545  return (int) (((char*)op)-dest);
546 }
#define unlikely(expr)
Definition: lz4.c:143
#define MINMATCH
Definition: lz4.c:220
unsigned int U32
Definition: lz4.c:175
#define LASTLITERALS
Definition: lz4.c:223
#define MAX_DISTANCE
Definition: lz4.c:231
#define LZ4_WRITE_LITTLEENDIAN_16(p, v)
Definition: lz4.c:284
FORCE_INLINE const BYTE * LZ4_getPosition(const BYTE *p, void *tableBase, tableType_t tableType, const BYTE *srcBase)
Definition: lz4.c:399
unsigned short U16
Definition: lz4.c:174
unsigned char BYTE
Definition: lz4.c:173
#define ML_BITS
Definition: lz4.c:233
#define SKIPSTRENGTH
Definition: lz4.c:228
const int LZ4_minLength
Definition: lz4.c:225
#define STEPSIZE
Definition: lz4.c:266
FORCE_INLINE int LZ4_hashPosition(const BYTE *p, tableType_t tableType)
Definition: lz4.c:374
#define A32(x)
Definition: lz4.c:208
#define LZ4_MAX_INPUT_SIZE
Definition: lz4.h:77
FORCE_INLINE void LZ4_putPosition(const BYTE *p, void *tableBase, tableType_t tableType, const BYTE *srcBase)
Definition: lz4.c:386
#define ML_MASK
Definition: lz4.c:234
#define LZ4_ARCH64
Definition: lz4.c:60
#define RUN_MASK
Definition: lz4.c:236
#define LZ4_64KLIMIT
Definition: lz4.c:227
FORCE_INLINE void LZ4_putPositionOnHash(const BYTE *p, U32 h, void *tableBase, tableType_t tableType, const BYTE *srcBase)
Definition: lz4.c:376
#define A16(x)
Definition: lz4.c:207
FORCE_INLINE const BYTE * LZ4_getPositionOnHash(U32 h, void *tableBase, tableType_t tableType, const BYTE *srcBase)
Definition: lz4.c:392
FORCE_INLINE int LZ4_NbCommonBytes(register U32 val)
Definition: lz4.c:331
#define AARCH(x)
Definition: lz4.c:210
#define likely(expr)
Definition: lz4.c:142
Definition: lz4.c:255
#define LZ4_WILDCOPY(d, s, e)
Definition: lz4.c:291
#define MFLIMIT
Definition: lz4.c:224

◆ LZ4_compress_limitedOutput()

int LZ4_compress_limitedOutput ( const char *  source,
char *  dest,
int  inputSize,
int  maxOutputSize 
)

Definition at line 569 of file lz4.c.

570 {
571 #if (HEAPMODE)
572  void* ctx = ALLOCATOR(HASHNBCELLS4, 4); // Aligned on 4-bytes boundaries
573 #else
574  U32 ctx[1U<<(MEMORY_USAGE-2)] = {0}; // Ensure data is aligned on 4-bytes boundaries
575 #endif
576  int result;
577 
578  if (inputSize < (int)LZ4_64KLIMIT)
579  result = LZ4_compress_generic((void*)ctx, source, dest, inputSize, maxOutputSize, limited, byU16, noPrefix);
580  else
581  result = LZ4_compress_generic((void*)ctx, source, dest, inputSize, maxOutputSize, limited, (sizeof(void*)==8) ? byU32 : byPtr, noPrefix);
582 
583 #if (HEAPMODE)
584  FREEMEM(ctx);
585 #endif
586  return result;
587 }
#define HASHNBCELLS4
Definition: lz4.c:218
unsigned int U32
Definition: lz4.c:175
#define FREEMEM
Definition: lz4.c:151
Definition: lz4.c:255
#define ALLOCATOR(n, s)
Definition: lz4.c:150
#define MEMORY_USAGE
Definition: lz4.c:42
Definition: lz4.c:254
Definition: lz4.c:255
FORCE_INLINE int LZ4_compress_generic(void *ctx, const char *source, char *dest, int inputSize, int maxOutputSize, limitedOutput_directive limitedOutput, tableType_t tableType, prefix64k_directive prefix)
Definition: lz4.c:406
#define LZ4_64KLIMIT
Definition: lz4.c:227
Definition: lz4.c:257
Definition: lz4.c:255

◆ LZ4_compress_limitedOutput_continue()

int LZ4_compress_limitedOutput_continue ( void *  LZ4_Data,
const char *  source,
char *  dest,
int  inputSize,
int  maxOutputSize 
)

Definition at line 697 of file lz4.c.

698 {
699  return LZ4_compress_generic(LZ4_Data, source, dest, inputSize, maxOutputSize, limited, byU32, withPrefix);
700 }
Definition: lz4.c:254
Definition: lz4.c:255
FORCE_INLINE int LZ4_compress_generic(void *ctx, const char *source, char *dest, int inputSize, int maxOutputSize, limitedOutput_directive limitedOutput, tableType_t tableType, prefix64k_directive prefix)
Definition: lz4.c:406

◆ LZ4_compress_limitedOutput_withState()

int LZ4_compress_limitedOutput_withState ( void *  state,
const char *  source,
char *  dest,
int  inputSize,
int  maxOutputSize 
)

Definition at line 609 of file lz4.c.

610 {
611  if (((size_t)(state)&3) != 0) return 0; // Error : state is not aligned on 4-bytes boundary
612  MEM_INIT(state, 0, LZ4_sizeofState());
613 
614  if (inputSize < (int)LZ4_64KLIMIT)
615  return LZ4_compress_generic(state, source, dest, inputSize, maxOutputSize, limited, byU16, noPrefix);
616  else
617  return LZ4_compress_generic(state, source, dest, inputSize, maxOutputSize, limited, (sizeof(void*)==8) ? byU32 : byPtr, noPrefix);
618 }
Definition: lz4.c:255
#define MEM_INIT
Definition: lz4.c:153
int LZ4_sizeofState()
Definition: lz4.c:594
Definition: lz4.c:254
Definition: lz4.c:255
FORCE_INLINE int LZ4_compress_generic(void *ctx, const char *source, char *dest, int inputSize, int maxOutputSize, limitedOutput_directive limitedOutput, tableType_t tableType, prefix64k_directive prefix)
Definition: lz4.c:406
#define LZ4_64KLIMIT
Definition: lz4.c:227
Definition: lz4.c:257
Definition: lz4.c:255

◆ LZ4_compress_withState()

int LZ4_compress_withState ( void *  state,
const char *  source,
char *  dest,
int  inputSize 
)

Definition at line 597 of file lz4.c.

598 {
599  if (((size_t)(state)&3) != 0) return 0; // Error : state is not aligned on 4-bytes boundary
600  MEM_INIT(state, 0, LZ4_sizeofState());
601 
602  if (inputSize < (int)LZ4_64KLIMIT)
603  return LZ4_compress_generic(state, source, dest, inputSize, 0, notLimited, byU16, noPrefix);
604  else
605  return LZ4_compress_generic(state, source, dest, inputSize, 0, notLimited, (sizeof(void*)==8) ? byU32 : byPtr, noPrefix);
606 }
Definition: lz4.c:255
#define MEM_INIT
Definition: lz4.c:153
int LZ4_sizeofState()
Definition: lz4.c:594
Definition: lz4.c:255
FORCE_INLINE int LZ4_compress_generic(void *ctx, const char *source, char *dest, int inputSize, int maxOutputSize, limitedOutput_directive limitedOutput, tableType_t tableType, prefix64k_directive prefix)
Definition: lz4.c:406
#define LZ4_64KLIMIT
Definition: lz4.c:227
Definition: lz4.c:257
Definition: lz4.c:255

◆ LZ4_create()

void* LZ4_create ( const char *  inputBuffer)

Definition at line 645 of file lz4.c.

646 {
647  void* lz4ds = ALLOCATOR(1, sizeof(LZ4_Data_Structure));
648  LZ4_init ((LZ4_Data_Structure*)lz4ds, (const BYTE*)inputBuffer);
649  return lz4ds;
650 }
unsigned char BYTE
Definition: lz4.c:173
FORCE_INLINE void LZ4_init(LZ4_Data_Structure *lz4ds, const BYTE *base)
Definition: lz4.c:630
#define ALLOCATOR(n, s)
Definition: lz4.c:150

◆ LZ4_decompress_fast()

int LZ4_decompress_fast ( const char *  source,
char *  dest,
int  outputSize 
)

Definition at line 857 of file lz4.c.

858 {
859 #ifdef _MSC_VER // This version is faster with Visual
860  return LZ4_decompress_generic(source, dest, 0, outputSize, endOnOutputSize, noPrefix, full, 0);
861 #else
862  return LZ4_decompress_generic(source, dest, 0, outputSize, endOnOutputSize, withPrefix, full, 0);
863 #endif
864 }
Definition: lz4.c:260
FORCE_INLINE int LZ4_decompress_generic(const char *source, char *dest, int inputSize, int outputSize, int endOnInput, int prefix64k, int partialDecoding, int targetOutputSize)
Definition: lz4.c:711
Definition: lz4.c:257

◆ LZ4_decompress_fast_withPrefix64k()

int LZ4_decompress_fast_withPrefix64k ( const char *  source,
char *  dest,
int  outputSize 
)

Definition at line 852 of file lz4.c.

853 {
854  return LZ4_decompress_generic(source, dest, 0, outputSize, endOnOutputSize, withPrefix, full, 0);
855 }
Definition: lz4.c:260
FORCE_INLINE int LZ4_decompress_generic(const char *source, char *dest, int inputSize, int outputSize, int endOnInput, int prefix64k, int partialDecoding, int targetOutputSize)
Definition: lz4.c:711

◆ LZ4_decompress_generic()

FORCE_INLINE int LZ4_decompress_generic ( const char *  source,
char *  dest,
int  inputSize,
int  outputSize,
int  endOnInput,
int  prefix64k,
int  partialDecoding,
int  targetOutputSize 
)

Definition at line 711 of file lz4.c.

722 {
723  // Local Variables
724  const BYTE* restrict ip = (const BYTE*) source;
725  const BYTE* ref;
726  const BYTE* const iend = ip + inputSize;
727 
728  BYTE* op = (BYTE*) dest;
729  BYTE* const oend = op + outputSize;
730  BYTE* cpy;
731  BYTE* oexit = op + targetOutputSize;
732 
733  const size_t dec32table[] = {0, 3, 2, 3, 0, 0, 0, 0}; // static reduces speed for LZ4_decompress_safe() on GCC64
734  static const size_t dec64table[] = {0, 0, 0, (size_t)-1, 0, 1, 2, 3};
735 
736 
737  // Special cases
738  if ((partialDecoding) && (oexit> oend-MFLIMIT)) oexit = oend-MFLIMIT; // targetOutputSize too high => decode everything
739  if ((endOnInput) && unlikely(outputSize==0)) return ((inputSize==1) && (*ip==0)) ? 0 : -1; // Empty output buffer
740  if ((!endOnInput) && unlikely(outputSize==0)) return (*ip==0?1:-1);
741 
742 
743  // Main Loop
744  while (1)
745  {
746  unsigned token;
747  size_t length;
748 
749  // get runlength
750  token = *ip++;
751  if ((length=(token>>ML_BITS)) == RUN_MASK)
752  {
753  unsigned s=255;
754  while (((endOnInput)?ip<iend:1) && (s==255))
755  {
756  s = *ip++;
757  length += s;
758  }
759  }
760 
761  // copy literals
762  cpy = op+length;
763  if (((endOnInput) && ((cpy>(partialDecoding?oexit:oend-MFLIMIT)) || (ip+length>iend-(2+1+LASTLITERALS))) )
764  || ((!endOnInput) && (cpy>oend-COPYLENGTH)))
765  {
766  if (partialDecoding)
767  {
768  if (cpy > oend) goto _output_error; // Error : write attempt beyond end of output buffer
769  if ((endOnInput) && (ip+length > iend)) goto _output_error; // Error : read attempt beyond end of input buffer
770  }
771  else
772  {
773  if ((!endOnInput) && (cpy != oend)) goto _output_error; // Error : block decoding must stop exactly there
774  if ((endOnInput) && ((ip+length != iend) || (cpy > oend))) goto _output_error; // Error : input must be consumed
775  }
776  memcpy(op, ip, length);
777  ip += length;
778  op += length;
779  break; // Necessarily EOF, due to parsing restrictions
780  }
781  LZ4_WILDCOPY(op, ip, cpy); ip -= (op-cpy); op = cpy;
782 
783  // get offset
784  LZ4_READ_LITTLEENDIAN_16(ref,cpy,ip); ip+=2;
785  if ((prefix64k==noPrefix) && unlikely(ref < (BYTE* const)dest)) goto _output_error; // Error : offset outside destination buffer
786 
787  // get matchlength
788  if ((length=(token&ML_MASK)) == ML_MASK)
789  {
790  while ((!endOnInput) || (ip<iend-(LASTLITERALS+1))) // Ensure enough bytes remain for LASTLITERALS + token
791  {
792  unsigned s = *ip++;
793  length += s;
794  if (s==255) continue;
795  break;
796  }
797  }
798 
799  // copy repeated sequence
800  if unlikely((op-ref)<(int)STEPSIZE)
801  {
802  const size_t dec64 = dec64table[(sizeof(void*)==4) ? 0 : op-ref];
803  op[0] = ref[0];
804  op[1] = ref[1];
805  op[2] = ref[2];
806  op[3] = ref[3];
807  op += 4, ref += 4; ref -= dec32table[op-ref];
808  A32(op) = A32(ref);
809  op += STEPSIZE-4; ref -= dec64;
810  } else { LZ4_COPYSTEP(op,ref); }
811  cpy = op + length - (STEPSIZE-4);
812 
813  if unlikely(cpy>oend-COPYLENGTH-(STEPSIZE-4))
814  {
815  if (cpy > oend-LASTLITERALS) goto _output_error; // Error : last 5 bytes must be literals
816  LZ4_SECURECOPY(op, ref, (oend-COPYLENGTH));
817  while(op<cpy) *op++=*ref++;
818  op=cpy;
819  continue;
820  }
821  LZ4_WILDCOPY(op, ref, cpy);
822  op=cpy; // correction
823  }
824 
825  // end of decoding
826  if (endOnInput)
827  return (int) (((char*)op)-dest); // Nb of output bytes decoded
828  else
829  return (int) (((char*)ip)-source); // Nb of input bytes read
830 
831  // Overflow error detected
832 _output_error:
833  return (int) (-(((char*)ip)-source))-1;
834 }
#define unlikely(expr)
Definition: lz4.c:143
#define LZ4_READ_LITTLEENDIAN_16(d, s, p)
Definition: lz4.c:283
#define LASTLITERALS
Definition: lz4.c:223
#define COPYLENGTH
Definition: lz4.c:222
#define LZ4_COPYSTEP(d, s)
Definition: lz4.c:267
unsigned char BYTE
Definition: lz4.c:173
#define ML_BITS
Definition: lz4.c:233
#define STEPSIZE
Definition: lz4.c:266
#define restrict
Definition: lz4.c:106
#define A32(x)
Definition: lz4.c:208
#define ML_MASK
Definition: lz4.c:234
#define LZ4_SECURECOPY(d, s, e)
Definition: lz4.c:269
#define RUN_MASK
Definition: lz4.c:236
Definition: lz4.c:257
#define LZ4_WILDCOPY(d, s, e)
Definition: lz4.c:291
#define MFLIMIT
Definition: lz4.c:224

◆ LZ4_decompress_safe()

int LZ4_decompress_safe ( const char *  source,
char *  dest,
int  inputSize,
int  maxOutputSize 
)

Definition at line 837 of file lz4.c.

838 {
839  return LZ4_decompress_generic(source, dest, inputSize, maxOutputSize, endOnInputSize, noPrefix, full, 0);
840 }
Definition: lz4.c:260
FORCE_INLINE int LZ4_decompress_generic(const char *source, char *dest, int inputSize, int outputSize, int endOnInput, int prefix64k, int partialDecoding, int targetOutputSize)
Definition: lz4.c:711
Definition: lz4.c:257

◆ LZ4_decompress_safe_partial()

int LZ4_decompress_safe_partial ( const char *  source,
char *  dest,
int  inputSize,
int  targetOutputSize,
int  maxOutputSize 
)

Definition at line 847 of file lz4.c.

848 {
849  return LZ4_decompress_generic(source, dest, inputSize, maxOutputSize, endOnInputSize, noPrefix, partial, targetOutputSize);
850 }
Definition: lz4.c:260
FORCE_INLINE int LZ4_decompress_generic(const char *source, char *dest, int inputSize, int outputSize, int endOnInput, int prefix64k, int partialDecoding, int targetOutputSize)
Definition: lz4.c:711
Definition: lz4.c:257

◆ LZ4_decompress_safe_withPrefix64k()

int LZ4_decompress_safe_withPrefix64k ( const char *  source,
char *  dest,
int  inputSize,
int  maxOutputSize 
)

Definition at line 842 of file lz4.c.

843 {
844  return LZ4_decompress_generic(source, dest, inputSize, maxOutputSize, endOnInputSize, withPrefix, full, 0);
845 }
Definition: lz4.c:260
FORCE_INLINE int LZ4_decompress_generic(const char *source, char *dest, int inputSize, int outputSize, int endOnInput, int prefix64k, int partialDecoding, int targetOutputSize)
Definition: lz4.c:711

◆ LZ4_free()

int LZ4_free ( void *  LZ4_Data)

Definition at line 653 of file lz4.c.

654 {
655  FREEMEM(LZ4_Data);
656  return (0);
657 }
#define FREEMEM
Definition: lz4.c:151

◆ LZ4_getPosition()

FORCE_INLINE const BYTE* LZ4_getPosition ( const BYTE p,
void *  tableBase,
tableType_t  tableType,
const BYTE srcBase 
)

Definition at line 399 of file lz4.c.

400 {
401  U32 h = LZ4_hashPosition(p, tableType);
402  return LZ4_getPositionOnHash(h, tableBase, tableType, srcBase);
403 }
unsigned int U32
Definition: lz4.c:175
FORCE_INLINE int LZ4_hashPosition(const BYTE *p, tableType_t tableType)
Definition: lz4.c:374
FORCE_INLINE const BYTE * LZ4_getPositionOnHash(U32 h, void *tableBase, tableType_t tableType, const BYTE *srcBase)
Definition: lz4.c:392

◆ LZ4_getPositionOnHash()

FORCE_INLINE const BYTE* LZ4_getPositionOnHash ( U32  h,
void *  tableBase,
tableType_t  tableType,
const BYTE srcBase 
)

Definition at line 392 of file lz4.c.

393 {
394  if (tableType == byPtr) { const BYTE** hashTable = (const BYTE**) tableBase; return hashTable[h]; }
395  if (tableType == byU32) { U32* hashTable = (U32*) tableBase; return hashTable[h] + srcBase; }
396  { U16* hashTable = (U16*) tableBase; return hashTable[h] + srcBase; } // default, to ensure a return
397 }
unsigned int U32
Definition: lz4.c:175
Definition: lz4.c:255
unsigned short U16
Definition: lz4.c:174
unsigned char BYTE
Definition: lz4.c:173
Definition: lz4.c:255

◆ LZ4_hashPosition()

FORCE_INLINE int LZ4_hashPosition ( const BYTE p,
tableType_t  tableType 
)

Definition at line 374 of file lz4.c.

374 { return LZ4_hashSequence(A32(p), tableType); }
FORCE_INLINE int LZ4_hashSequence(U32 sequence, tableType_t tableType)
Definition: lz4.c:366
#define A32(x)
Definition: lz4.c:208

◆ LZ4_hashSequence()

FORCE_INLINE int LZ4_hashSequence ( U32  sequence,
tableType_t  tableType 
)

Definition at line 366 of file lz4.c.

367 {
368  if (tableType == byU16)
369  return (((sequence) * 2654435761U) >> ((MINMATCH*8)-(LZ4_HASHLOG+1)));
370  else
371  return (((sequence) * 2654435761U) >> ((MINMATCH*8)-LZ4_HASHLOG));
372 }
#define MINMATCH
Definition: lz4.c:220
#define LZ4_HASHLOG
Definition: lz4.c:216
Definition: lz4.c:255

◆ LZ4_init()

FORCE_INLINE void LZ4_init ( LZ4_Data_Structure lz4ds,
const BYTE base 
)

Definition at line 630 of file lz4.c.

631 {
632  MEM_INIT(lz4ds->hashTable, 0, sizeof(lz4ds->hashTable));
633  lz4ds->bufferStart = base;
634  lz4ds->base = base;
635  lz4ds->nextBlock = base;
636 }
const BYTE * base
Definition: lz4.c:250
U32 hashTable[HASHNBCELLS4]
Definition: lz4.c:248
const BYTE * nextBlock
Definition: lz4.c:251
#define MEM_INIT
Definition: lz4.c:153
const BYTE * bufferStart
Definition: lz4.c:249

◆ LZ4_NbCommonBytes()

FORCE_INLINE int LZ4_NbCommonBytes ( register U32  val)

Definition at line 331 of file lz4.c.

332 {
333 # if defined(LZ4_BIG_ENDIAN)
334 # if defined(_MSC_VER) && !defined(LZ4_FORCE_SW_BITCOUNT)
335  unsigned long r = 0;
336  _BitScanReverse( &r, val );
337  return (int)(r>>3);
338 # elif defined(__GNUC__) && (GCC_VERSION >= 304) && !defined(LZ4_FORCE_SW_BITCOUNT)
339  return (__builtin_clz(val) >> 3);
340 # else
341  int r;
342  if (!(val>>16)) { r=2; val>>=8; } else { r=0; val>>=24; }
343  r += (!val);
344  return r;
345 # endif
346 # else
347 # if defined(_MSC_VER) && !defined(LZ4_FORCE_SW_BITCOUNT)
348  unsigned long r;
349  _BitScanForward( &r, val );
350  return (int)(r>>3);
351 # elif defined(__GNUC__) && (GCC_VERSION >= 304) && !defined(LZ4_FORCE_SW_BITCOUNT)
352  return (__builtin_ctz(val) >> 3);
353 # else
354  static const int DeBruijnBytePos[32] = { 0, 0, 3, 0, 3, 1, 3, 0, 3, 2, 2, 1, 3, 2, 0, 1, 3, 3, 1, 2, 2, 2, 2, 0, 3, 1, 2, 0, 1, 0, 1, 1 };
355  return DeBruijnBytePos[((U32)((val & -(S32)val) * 0x077CB531U)) >> 27];
356 # endif
357 # endif
358 }
unsigned int U32
Definition: lz4.c:175
signed int S32
Definition: lz4.c:176

◆ LZ4_putPosition()

FORCE_INLINE void LZ4_putPosition ( const BYTE p,
void *  tableBase,
tableType_t  tableType,
const BYTE srcBase 
)

Definition at line 386 of file lz4.c.

387 {
388  U32 h = LZ4_hashPosition(p, tableType);
389  LZ4_putPositionOnHash(p, h, tableBase, tableType, srcBase);
390 }
unsigned int U32
Definition: lz4.c:175
FORCE_INLINE int LZ4_hashPosition(const BYTE *p, tableType_t tableType)
Definition: lz4.c:374
FORCE_INLINE void LZ4_putPositionOnHash(const BYTE *p, U32 h, void *tableBase, tableType_t tableType, const BYTE *srcBase)
Definition: lz4.c:376

◆ LZ4_putPositionOnHash()

FORCE_INLINE void LZ4_putPositionOnHash ( const BYTE p,
U32  h,
void *  tableBase,
tableType_t  tableType,
const BYTE srcBase 
)

Definition at line 376 of file lz4.c.

377 {
378  switch (tableType)
379  {
380  case byPtr: { const BYTE** hashTable = (const BYTE**) tableBase; hashTable[h] = p; break; }
381  case byU32: { U32* hashTable = (U32*) tableBase; hashTable[h] = (U32)(p-srcBase); break; }
382  case byU16: { U16* hashTable = (U16*) tableBase; hashTable[h] = (U16)(p-srcBase); break; }
383  }
384 }
unsigned int U32
Definition: lz4.c:175
Definition: lz4.c:255
unsigned short U16
Definition: lz4.c:174
unsigned char BYTE
Definition: lz4.c:173
Definition: lz4.c:255
Definition: lz4.c:255

◆ LZ4_resetStreamState()

int LZ4_resetStreamState ( void *  state,
const char *  inputBuffer 
)

Definition at line 638 of file lz4.c.

639 {
640  if ((((size_t)state) & 3) != 0) return 1; // Error : pointer is not aligned on 4-bytes boundary
641  LZ4_init((LZ4_Data_Structure*)state, (const BYTE*)inputBuffer);
642  return 0;
643 }
unsigned char BYTE
Definition: lz4.c:173
FORCE_INLINE void LZ4_init(LZ4_Data_Structure *lz4ds, const BYTE *base)
Definition: lz4.c:630

◆ LZ4_sizeofState()

int LZ4_sizeofState ( )

Definition at line 594 of file lz4.c.

594 { return 1 << MEMORY_USAGE; }
#define MEMORY_USAGE
Definition: lz4.c:42

◆ LZ4_sizeofStreamState()

int LZ4_sizeofStreamState ( )

Definition at line 625 of file lz4.c.

626 {
627  return sizeof(LZ4_Data_Structure);
628 }

◆ LZ4_slideInputBuffer()

char* LZ4_slideInputBuffer ( void *  LZ4_Data)

Definition at line 660 of file lz4.c.

661 {
662  LZ4_Data_Structure* lz4ds = (LZ4_Data_Structure*)LZ4_Data;
663  size_t delta = lz4ds->nextBlock - (lz4ds->bufferStart + 64 KB);
664 
665  if ( (lz4ds->base - delta > lz4ds->base) // underflow control
666  || ((size_t)(lz4ds->nextBlock - lz4ds->base) > 0xE0000000) ) // close to 32-bits limit
667  {
668  size_t deltaLimit = (lz4ds->nextBlock - 64 KB) - lz4ds->base;
669  int nH;
670 
671  for (nH=0; nH < HASHNBCELLS4; nH++)
672  {
673  if ((size_t)(lz4ds->hashTable[nH]) < deltaLimit) lz4ds->hashTable[nH] = 0;
674  else lz4ds->hashTable[nH] -= (U32)deltaLimit;
675  }
676  memcpy((void*)(lz4ds->bufferStart), (const void*)(lz4ds->nextBlock - 64 KB), 64 KB);
677  lz4ds->base = lz4ds->bufferStart;
678  lz4ds->nextBlock = lz4ds->base + 64 KB;
679  }
680  else
681  {
682  memcpy((void*)(lz4ds->bufferStart), (const void*)(lz4ds->nextBlock - 64 KB), 64 KB);
683  lz4ds->nextBlock -= delta;
684  lz4ds->base -= delta;
685  }
686 
687  return (char*)(lz4ds->nextBlock);
688 }
#define HASHNBCELLS4
Definition: lz4.c:218
unsigned int U32
Definition: lz4.c:175
const BYTE * base
Definition: lz4.c:250
U32 hashTable[HASHNBCELLS4]
Definition: lz4.c:248
const BYTE * nextBlock
Definition: lz4.c:251
#define KB
Definition: lz4.c:238
const BYTE * bufferStart
Definition: lz4.c:249

Variable Documentation

◆ LZ4_minLength

const int LZ4_minLength = (MFLIMIT+1)

Definition at line 225 of file lz4.c.