🎩 You're Invited:Meet the Socket team at Black Hat in Las Vegas, August 3-6.RSVP
Sign In

lmdb

Package Overview
Dependencies
Maintainers
3
Versions
197
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

lmdb - npm Package Compare versions

Comparing version
3.4.3
to
3.4.4
+1
-0
dependencies/lz4/lib/liblz4.pc.in

@@ -12,4 +12,5 @@ # LZ4 - Fast LZ compression algorithm

URL: http://www.lz4.org/
License: BSD-2-Clause
Version: @VERSION@
Libs: -L${libdir} -llz4
Cflags: -I${includedir}
+120
-76
/*
* LZ4 - Fast LZ compression algorithm
* Header File
* Copyright (C) 2011-2020, Yann Collet.
* Copyright (c) Yann Collet. All rights reserved.

@@ -132,4 +132,4 @@ BSD 2-Clause License (http://www.opensource.org/licenses/bsd-license.php)

#define LZ4_VERSION_MAJOR 1 /* for breaking interface changes */
#define LZ4_VERSION_MINOR 9 /* for new (non-breaking) interface capabilities */
#define LZ4_VERSION_RELEASE 4 /* for tweaks, bug-fixes, or development */
#define LZ4_VERSION_MINOR 10 /* for new (non-breaking) interface capabilities */
#define LZ4_VERSION_RELEASE 0 /* for tweaks, bug-fixes, or development */

@@ -148,14 +148,11 @@ #define LZ4_VERSION_NUMBER (LZ4_VERSION_MAJOR *100*100 + LZ4_VERSION_MINOR *100 + LZ4_VERSION_RELEASE)

/*-************************************
* Tuning parameter
* Tuning memory usage
**************************************/
#define LZ4_MEMORY_USAGE_MIN 10
#define LZ4_MEMORY_USAGE_DEFAULT 14
#define LZ4_MEMORY_USAGE_MAX 20
/*!
* LZ4_MEMORY_USAGE :
* Memory usage formula : N->2^N Bytes (examples : 10 -> 1KB; 12 -> 4KB ; 16 -> 64KB; 20 -> 1MB; )
* Increasing memory usage improves compression ratio, at the cost of speed.
* Can be selected at compile time, by setting LZ4_MEMORY_USAGE.
* Memory usage formula : N->2^N Bytes (examples : 10 -> 1KB; 12 -> 4KB ; 16 -> 64KB; 20 -> 1MB)
* Increasing memory usage improves compression ratio, generally at the cost of speed.
* Reduced memory usage may improve speed at the cost of ratio, thanks to better cache locality.
* Default value is 14, for 16KB, which nicely fits into Intel x86 L1 cache
* Default value is 14, for 16KB, which nicely fits into most L1 caches.
*/

@@ -166,2 +163,7 @@ #ifndef LZ4_MEMORY_USAGE

/* These are absolute limits, they should not be changed by users */
#define LZ4_MEMORY_USAGE_MIN 10
#define LZ4_MEMORY_USAGE_DEFAULT 14
#define LZ4_MEMORY_USAGE_MAX 20
#if (LZ4_MEMORY_USAGE < LZ4_MEMORY_USAGE_MIN)

@@ -195,4 +197,5 @@ # error "LZ4_MEMORY_USAGE is too small !"

/*! LZ4_decompress_safe() :
* compressedSize : is the exact complete size of the compressed block.
* dstCapacity : is the size of destination buffer (which must be already allocated), presumed an upper bound of decompressed size.
* @compressedSize : is the exact complete size of the compressed block.
* @dstCapacity : is the size of destination buffer (which must be already allocated),
* presumed an upper bound of decompressed size.
* @return : the number of bytes decompressed into destination buffer (necessarily <= dstCapacity)

@@ -249,6 +252,5 @@ * If destination buffer is not large enough, decoding will stop and output an error code (negative value).

/*! LZ4_compress_destSize() :
* Reverse the logic : compresses as much data as possible from 'src' buffer
* into already allocated buffer 'dst', of size >= 'targetDestSize'.
* into already allocated buffer 'dst', of size >= 'dstCapacity'.
* This function either compresses the entire 'src' content into 'dst' if it's large enough,

@@ -258,11 +260,14 @@ * or fill 'dst' buffer completely with as much data as possible from 'src'.

*
* *srcSizePtr : will be modified to indicate how many bytes where read from 'src' to fill 'dst'.
* *srcSizePtr : in+out parameter. Initially contains size of input.
* Will be modified to indicate how many bytes where read from 'src' to fill 'dst'.
* New value is necessarily <= input value.
* @return : Nb bytes written into 'dst' (necessarily <= targetDestSize)
* @return : Nb bytes written into 'dst' (necessarily <= dstCapacity)
* or 0 if compression fails.
*
* Note : from v1.8.2 to v1.9.1, this function had a bug (fixed un v1.9.2+):
* the produced compressed content could, in specific circumstances,
* require to be decompressed into a destination buffer larger
* by at least 1 byte than the content to decompress.
* Note : 'targetDstSize' must be >= 1, because it's the smallest valid lz4 payload.
*
* Note 2:from v1.8.2 to v1.9.1, this function had a bug (fixed in v1.9.2+):
* the produced compressed content could, in rare circumstances,
* require to be decompressed into a destination buffer
* larger by at least 1 byte than decompressesSize.
* If an application uses `LZ4_compress_destSize()`,

@@ -275,5 +280,4 @@ * it's highly recommended to update liblz4 to v1.9.2 or better.

*/
LZ4LIB_API int LZ4_compress_destSize (const char* src, char* dst, int* srcSizePtr, int targetDstSize);
LZ4LIB_API int LZ4_compress_destSize(const char* src, char* dst, int* srcSizePtr, int targetDstSize);
/*! LZ4_decompress_safe_partial() :

@@ -321,3 +325,3 @@ * Decompress an LZ4 compressed block, of size 'srcSize' at position 'src',

/**
/*!
Note about RC_INVOKED

@@ -372,9 +376,54 @@

* Dictionary are useful for better compression of small data (KB range).
* While LZ4 accept any input as dictionary,
* results are generally better when using Zstandard's Dictionary Builder.
* While LZ4 itself accepts any input as dictionary, dictionary efficiency is also a topic.
* When in doubt, employ the Zstandard's Dictionary Builder.
* Loading a size of 0 is allowed, and is the same as reset.
* @return : loaded dictionary size, in bytes (necessarily <= 64 KB)
* @return : loaded dictionary size, in bytes (note: only the last 64 KB are loaded)
*/
LZ4LIB_API int LZ4_loadDict (LZ4_stream_t* streamPtr, const char* dictionary, int dictSize);
/*! LZ4_loadDictSlow() : v1.10.0+
* Same as LZ4_loadDict(),
* but uses a bit more cpu to reference the dictionary content more thoroughly.
* This is expected to slightly improve compression ratio.
* The extra-cpu cost is likely worth it if the dictionary is re-used across multiple sessions.
* @return : loaded dictionary size, in bytes (note: only the last 64 KB are loaded)
*/
LZ4LIB_API int LZ4_loadDictSlow(LZ4_stream_t* streamPtr, const char* dictionary, int dictSize);
/*! LZ4_attach_dictionary() : stable since v1.10.0
*
* This allows efficient re-use of a static dictionary multiple times.
*
* Rather than re-loading the dictionary buffer into a working context before
* each compression, or copying a pre-loaded dictionary's LZ4_stream_t into a
* working LZ4_stream_t, this function introduces a no-copy setup mechanism,
* in which the working stream references @dictionaryStream in-place.
*
* Several assumptions are made about the state of @dictionaryStream.
* Currently, only states which have been prepared by LZ4_loadDict() or
* LZ4_loadDictSlow() should be expected to work.
*
* Alternatively, the provided @dictionaryStream may be NULL,
* in which case any existing dictionary stream is unset.
*
* If a dictionary is provided, it replaces any pre-existing stream history.
* The dictionary contents are the only history that can be referenced and
* logically immediately precede the data compressed in the first subsequent
* compression call.
*
* The dictionary will only remain attached to the working stream through the
* first compression call, at the end of which it is cleared.
* @dictionaryStream stream (and source buffer) must remain in-place / accessible / unchanged
* through the completion of the compression session.
*
* Note: there is no equivalent LZ4_attach_*() method on the decompression side
* because there is no initialization cost, hence no need to share the cost across multiple sessions.
* To decompress LZ4 blocks using dictionary, attached or not,
* just employ the regular LZ4_setStreamDecode() for streaming,
* or the stateless LZ4_decompress_safe_usingDict() for one-shot decompression.
*/
LZ4LIB_API void
LZ4_attach_dictionary(LZ4_stream_t* workingStream,
const LZ4_stream_t* dictionaryStream);
/*! LZ4_compress_fast_continue() :

@@ -455,7 +504,20 @@ * Compress 'src' content using data from previously compressed blocks, for better compression ratio.

/*! LZ4_decompress_*_continue() :
* These decoding functions allow decompression of consecutive blocks in "streaming" mode.
* A block is an unsplittable entity, it must be presented entirely to a decompression function.
* Decompression functions only accepts one block at a time.
* The last 64KB of previously decoded data *must* remain available and unmodified at the memory position where they were decoded.
/*! LZ4_decompress_safe_continue() :
* This decoding function allows decompression of consecutive blocks in "streaming" mode.
* The difference with the usual independent blocks is that
* new blocks are allowed to find references into former blocks.
* A block is an unsplittable entity, and must be presented entirely to the decompression function.
* LZ4_decompress_safe_continue() only accepts one block at a time.
* It's modeled after `LZ4_decompress_safe()` and behaves similarly.
*
* @LZ4_streamDecode : decompression state, tracking the position in memory of past data
* @compressedSize : exact complete size of one compressed block.
* @dstCapacity : size of destination buffer (which must be already allocated),
* must be an upper bound of decompressed size.
* @return : number of bytes decompressed into destination buffer (necessarily <= dstCapacity)
* If destination buffer is not large enough, decoding will stop and output an error code (negative value).
* If the source stream is detected malformed, the function will stop decoding and return a negative result.
*
* The last 64KB of previously decoded data *must* remain available and unmodified
* at the memory position where they were previously decoded.
* If less than 64KB of data has been decoded, all the data must be present.

@@ -487,6 +549,6 @@ *

/*! LZ4_decompress_*_usingDict() :
* These decoding functions work the same as
* a combination of LZ4_setStreamDecode() followed by LZ4_decompress_*_continue()
* They are stand-alone, and don't need an LZ4_streamDecode_t structure.
/*! LZ4_decompress_safe_usingDict() :
* Works the same as
* a combination of LZ4_setStreamDecode() followed by LZ4_decompress_safe_continue()
* However, it's stateless: it doesn't need any LZ4_streamDecode_t state.
* Dictionary is presumed stable : it must remain accessible and unmodified during decompression.

@@ -501,2 +563,8 @@ * Performance tip : Decompression speed can be substantially increased

/*! LZ4_decompress_safe_partial_usingDict() :
* Behaves the same as LZ4_decompress_safe_partial()
* with the added ability to specify a memory segment for past data.
* Performance tip : Decompression speed can be substantially increased
* when dst == dictStart + dictSize.
*/
LZ4LIB_API int

@@ -541,5 +609,5 @@ LZ4_decompress_safe_partial_usingDict(const char* src, char* dst,

#ifdef LZ4_PUBLISH_STATIC_FUNCTIONS
#define LZ4LIB_STATIC_API LZ4LIB_API
# define LZ4LIB_STATIC_API LZ4LIB_API
#else
#define LZ4LIB_STATIC_API
# define LZ4LIB_STATIC_API
#endif

@@ -560,33 +628,8 @@

/*! LZ4_attach_dictionary() :
* This is an experimental API that allows
* efficient use of a static dictionary many times.
*
* Rather than re-loading the dictionary buffer into a working context before
* each compression, or copying a pre-loaded dictionary's LZ4_stream_t into a
* working LZ4_stream_t, this function introduces a no-copy setup mechanism,
* in which the working stream references the dictionary stream in-place.
*
* Several assumptions are made about the state of the dictionary stream.
* Currently, only streams which have been prepared by LZ4_loadDict() should
* be expected to work.
*
* Alternatively, the provided dictionaryStream may be NULL,
* in which case any existing dictionary stream is unset.
*
* If a dictionary is provided, it replaces any pre-existing stream history.
* The dictionary contents are the only history that can be referenced and
* logically immediately precede the data compressed in the first subsequent
* compression call.
*
* The dictionary will only remain attached to the working stream through the
* first compression call, at the end of which it is cleared. The dictionary
* stream (and source buffer) must remain in-place / accessible / unchanged
* through the completion of the first compression call on the stream.
/*! LZ4_compress_destSize_extState() : introduced in v1.10.0
* Same as LZ4_compress_destSize(), but using an externally allocated state.
* Also: exposes @acceleration
*/
LZ4LIB_STATIC_API void
LZ4_attach_dictionary(LZ4_stream_t* workingStream,
const LZ4_stream_t* dictionaryStream);
int LZ4_compress_destSize_extState(void* state, const char* src, char* dst, int* srcSizePtr, int targetDstSize, int acceleration);
/*! In-place compression and decompression

@@ -674,6 +717,6 @@ *

# include <stdint.h>
typedef int8_t LZ4_i8;
typedef uint8_t LZ4_byte;
typedef uint16_t LZ4_u16;
typedef uint32_t LZ4_u32;
typedef int8_t LZ4_i8;
typedef unsigned char LZ4_byte;
typedef uint16_t LZ4_u16;
typedef uint32_t LZ4_u32;
#else

@@ -703,3 +746,3 @@ typedef signed char LZ4_i8;

#define LZ4_STREAM_MINSIZE ((1UL << LZ4_MEMORY_USAGE) + 32) /* static size, for inter-version compatibility */
#define LZ4_STREAM_MINSIZE ((1UL << (LZ4_MEMORY_USAGE)) + 32) /* static size, for inter-version compatibility */
union LZ4_stream_u {

@@ -725,3 +768,3 @@ char minStateSize[LZ4_STREAM_MINSIZE];

**/
LZ4LIB_API LZ4_stream_t* LZ4_initStream (void* buffer, size_t size);
LZ4LIB_API LZ4_stream_t* LZ4_initStream (void* stateBuffer, size_t size);

@@ -838,7 +881,8 @@

*/
LZ4_DEPRECATED("This function is deprecated and unsafe. Consider using LZ4_decompress_safe() instead")
LZ4_DEPRECATED("This function is deprecated and unsafe. Consider using LZ4_decompress_safe_partial() instead")
LZ4LIB_API int LZ4_decompress_fast (const char* src, char* dst, int originalSize);
LZ4_DEPRECATED("This function is deprecated and unsafe. Consider using LZ4_decompress_safe_continue() instead")
LZ4_DEPRECATED("This function is deprecated and unsafe. Consider migrating towards LZ4_decompress_safe_continue() instead. "
"Note that the contract will change (requires block's compressed size, instead of decompressed size)")
LZ4LIB_API int LZ4_decompress_fast_continue (LZ4_streamDecode_t* LZ4_streamDecode, const char* src, char* dst, int originalSize);
LZ4_DEPRECATED("This function is deprecated and unsafe. Consider using LZ4_decompress_safe_usingDict() instead")
LZ4_DEPRECATED("This function is deprecated and unsafe. Consider using LZ4_decompress_safe_partial_usingDict() instead")
LZ4LIB_API int LZ4_decompress_fast_usingDict (const char* src, char* dst, int originalSize, const char* dictStart, int dictSize);

@@ -845,0 +889,0 @@

/*
* LZ4 file library
* Copyright (C) 2022, Xiaomi Inc.
* Copyright (c) Yann Collet and LZ4 contributors. All rights reserved.
*

@@ -34,7 +34,19 @@ * BSD 2-Clause License (http://www.opensource.org/licenses/bsd-license.php)

*/
#include <stdlib.h>
#include <stdlib.h> /* malloc, free */
#include <string.h>
#include <assert.h>
#include "lz4.h"
#include "lz4file.h"
/* ===== Error Handling ===== */
static LZ4F_errorCode_t returnErrorCode(LZ4F_errorCodes code)
{
return (LZ4F_errorCode_t)-(ptrdiff_t)code;
}
#undef RETURN_ERROR
#define RETURN_ERROR(e) return returnErrorCode(LZ4F_ERROR_ ## e)
/* ===== Read API Implementation ===== */
struct LZ4_readFile_s {

@@ -49,78 +61,94 @@ LZ4F_dctx* dctxPtr;

struct LZ4_writeFile_s {
LZ4F_cctx* cctxPtr;
FILE* fp;
LZ4_byte* dstBuf;
size_t maxWriteSize;
size_t dstBufMaxSize;
LZ4F_errorCode_t errCode;
};
static void freeReadFileResources(LZ4_readFile_t* lz4fRead)
{
if (lz4fRead==NULL) return;
LZ4F_freeDecompressionContext(lz4fRead->dctxPtr);
free(lz4fRead->srcBuf);
free(lz4fRead);
}
LZ4F_errorCode_t LZ4F_readOpen(LZ4_readFile_t** lz4fRead, FILE* fp)
static void freeAndNullReadFile(LZ4_readFile_t** statePtr)
{
char buf[LZ4F_HEADER_SIZE_MAX];
size_t consumedSize;
LZ4F_errorCode_t ret;
LZ4F_frameInfo_t info;
assert(statePtr != NULL);
freeReadFileResources(*statePtr);
*statePtr = NULL;
}
if (fp == NULL || lz4fRead == NULL) {
return -LZ4F_ERROR_GENERIC;
}
static LZ4F_errorCode_t readAndParseHeader(LZ4_readFile_t* readFile, FILE* fp)
{
char headerBuf[LZ4F_HEADER_SIZE_MAX];
LZ4F_frameInfo_t frameInfo;
size_t consumedSize;
*lz4fRead = (LZ4_readFile_t*)calloc(1, sizeof(LZ4_readFile_t));
if (*lz4fRead == NULL) {
return -LZ4F_ERROR_allocation_failed;
}
/* Read the header from file */
const size_t bytesRead = fread(headerBuf, 1, sizeof(headerBuf), fp);
if (bytesRead < LZ4F_HEADER_SIZE_MIN + LZ4F_ENDMARK_SIZE) {
RETURN_ERROR(io_read);
}
ret = LZ4F_createDecompressionContext(&(*lz4fRead)->dctxPtr, LZ4F_getVersion());
if (LZ4F_isError(ret)) {
free(*lz4fRead);
return ret;
}
/* Parse frame information */
consumedSize = bytesRead;
{ const LZ4F_errorCode_t result = LZ4F_getFrameInfo(readFile->dctxPtr, &frameInfo, headerBuf, &consumedSize);
if (LZ4F_isError(result)) {
return result;
} }
(*lz4fRead)->fp = fp;
consumedSize = fread(buf, 1, sizeof(buf), (*lz4fRead)->fp);
if (consumedSize != sizeof(buf)) {
free(*lz4fRead);
return -LZ4F_ERROR_GENERIC;
}
/* Determine buffer size based on block size */
{ const size_t blockSize = LZ4F_getBlockSize(frameInfo.blockSizeID);
if (blockSize == 0) {
RETURN_ERROR(maxBlockSize_invalid);
}
readFile->srcBufMaxSize = blockSize;
}
ret = LZ4F_getFrameInfo((*lz4fRead)->dctxPtr, &info, buf, &consumedSize);
if (LZ4F_isError(ret)) {
LZ4F_freeDecompressionContext((*lz4fRead)->dctxPtr);
free(*lz4fRead);
return ret;
/* Allocate source buffer */
assert(readFile->srcBuf == NULL); /* Should be NULL from calloc */
readFile->srcBuf = (LZ4_byte*)malloc(readFile->srcBufMaxSize);
if (readFile->srcBuf == NULL) {
RETURN_ERROR(allocation_failed);
}
switch (info.blockSizeID) {
case LZ4F_default :
case LZ4F_max64KB :
(*lz4fRead)->srcBufMaxSize = 64 * 1024;
break;
case LZ4F_max256KB:
(*lz4fRead)->srcBufMaxSize = 256 * 1024;
break;
case LZ4F_max1MB:
(*lz4fRead)->srcBufMaxSize = 1 * 1024 * 1024;
break;
case LZ4F_max4MB:
(*lz4fRead)->srcBufMaxSize = 4 * 1024 * 1024;
break;
default:
LZ4F_freeDecompressionContext((*lz4fRead)->dctxPtr);
free(*lz4fRead);
return -LZ4F_ERROR_maxBlockSize_invalid;
}
/* Store remaining header data in buffer */
readFile->srcBufSize = bytesRead - consumedSize;
if (readFile->srcBufSize > 0) {
memcpy(readFile->srcBuf, headerBuf + consumedSize, readFile->srcBufSize);
}
readFile->srcBufNext = 0;
(*lz4fRead)->srcBuf = (LZ4_byte*)malloc((*lz4fRead)->srcBufMaxSize);
if ((*lz4fRead)->srcBuf == NULL) {
LZ4F_freeDecompressionContext((*lz4fRead)->dctxPtr);
free(lz4fRead);
return -LZ4F_ERROR_allocation_failed;
}
return LZ4F_OK_NoError;
}
(*lz4fRead)->srcBufSize = sizeof(buf) - consumedSize;
memcpy((*lz4fRead)->srcBuf, buf + consumedSize, (*lz4fRead)->srcBufSize);
LZ4F_errorCode_t LZ4F_readOpen(LZ4_readFile_t** lz4fRead, FILE* fp)
{
LZ4_readFile_t* readFile;
return ret;
/* Validate parameters */
if (fp == NULL || lz4fRead == NULL) {
RETURN_ERROR(parameter_null);
}
/* Allocate read file structure */
readFile = (LZ4_readFile_t*)calloc(1, sizeof(LZ4_readFile_t));
if (readFile == NULL) {
RETURN_ERROR(allocation_failed);
}
readFile->fp = fp;
/* Initialize decompression context */
{ LZ4F_errorCode_t const result = LZ4F_createDecompressionContext(&readFile->dctxPtr, LZ4F_VERSION);
if (LZ4F_isError(result)) {
freeAndNullReadFile(&readFile);
return result;
} }
/* Read and parse the header */
{ LZ4F_errorCode_t const result = readAndParseHeader(readFile, fp);
if (LZ4F_isError(result)) {
freeAndNullReadFile(&readFile);
return result;
} }
*lz4fRead = readFile;
return LZ4F_OK_NoError;
}

@@ -130,43 +158,42 @@

{
LZ4_byte* p = (LZ4_byte*)buf;
size_t next = 0;
LZ4_byte* outPtr = (LZ4_byte*)buf;
size_t totalBytesRead = 0;
if (lz4fRead == NULL || buf == NULL)
return -LZ4F_ERROR_GENERIC;
RETURN_ERROR(parameter_null);
while (next < size) {
size_t srcsize = lz4fRead->srcBufSize - lz4fRead->srcBufNext;
size_t dstsize = size - next;
size_t ret;
while (totalBytesRead < size) {
size_t srcBytes = lz4fRead->srcBufSize - lz4fRead->srcBufNext;
size_t dstBytes = size - totalBytesRead;
if (srcsize == 0) {
ret = fread(lz4fRead->srcBuf, 1, lz4fRead->srcBufMaxSize, lz4fRead->fp);
if (ret > 0) {
lz4fRead->srcBufSize = ret;
srcsize = lz4fRead->srcBufSize;
lz4fRead->srcBufNext = 0;
if (srcBytes == 0) {
size_t const bytesRead = fread(lz4fRead->srcBuf, 1, lz4fRead->srcBufMaxSize, lz4fRead->fp);
if (bytesRead == 0) {
if (ferror(lz4fRead->fp)) {
RETURN_ERROR(io_read);
}
break; /* end of input reached */
}
else if (ret == 0) {
break;
}
else {
return -LZ4F_ERROR_GENERIC;
}
/* success: ret > 0*/
lz4fRead->srcBufSize = bytesRead;
srcBytes = lz4fRead->srcBufSize;
lz4fRead->srcBufNext = 0;
}
ret = LZ4F_decompress(lz4fRead->dctxPtr,
p, &dstsize,
{ size_t const decStatus = LZ4F_decompress(
lz4fRead->dctxPtr,
outPtr, &dstBytes,
lz4fRead->srcBuf + lz4fRead->srcBufNext,
&srcsize,
&srcBytes,
NULL);
if (LZ4F_isError(ret)) {
return ret;
}
if (LZ4F_isError(decStatus)) {
return decStatus;
} }
lz4fRead->srcBufNext += srcsize;
next += dstsize;
p += dstsize;
lz4fRead->srcBufNext += srcBytes;
totalBytesRead += dstBytes;
outPtr += dstBytes;
}
return next;
return totalBytesRead;
}

@@ -177,109 +204,134 @@

if (lz4fRead == NULL)
return -LZ4F_ERROR_GENERIC;
LZ4F_freeDecompressionContext(lz4fRead->dctxPtr);
free(lz4fRead->srcBuf);
free(lz4fRead);
RETURN_ERROR(parameter_null);
freeReadFileResources(lz4fRead);
return LZ4F_OK_NoError;
}
LZ4F_errorCode_t LZ4F_writeOpen(LZ4_writeFile_t** lz4fWrite, FILE* fp, const LZ4F_preferences_t* prefsPtr)
/* ===== write API ===== */
struct LZ4_writeFile_s {
LZ4F_cctx* cctxPtr;
FILE* fp;
LZ4_byte* dstBuf;
size_t maxWriteSize;
size_t dstBufMaxSize;
LZ4F_errorCode_t errCode;
};
static void freeWriteFileResources(LZ4_writeFile_t* state)
{
LZ4_byte buf[LZ4F_HEADER_SIZE_MAX];
size_t ret;
if (state == NULL) return;
LZ4F_freeCompressionContext(state->cctxPtr);
free(state->dstBuf);
free(state);
}
if (fp == NULL || lz4fWrite == NULL)
return -LZ4F_ERROR_GENERIC;
static void freeAndNullWriteFile(LZ4_writeFile_t** statePtr)
{
assert(statePtr != NULL);
freeWriteFileResources(*statePtr);
*statePtr = NULL;
}
*lz4fWrite = (LZ4_writeFile_t*)malloc(sizeof(LZ4_writeFile_t));
if (*lz4fWrite == NULL) {
return -LZ4F_ERROR_allocation_failed;
}
if (prefsPtr != NULL) {
switch (prefsPtr->frameInfo.blockSizeID) {
case LZ4F_default :
case LZ4F_max64KB :
(*lz4fWrite)->maxWriteSize = 64 * 1024;
break;
case LZ4F_max256KB:
(*lz4fWrite)->maxWriteSize = 256 * 1024;
break;
case LZ4F_max1MB:
(*lz4fWrite)->maxWriteSize = 1 * 1024 * 1024;
break;
case LZ4F_max4MB:
(*lz4fWrite)->maxWriteSize = 4 * 1024 * 1024;
break;
default:
free(lz4fWrite);
return -LZ4F_ERROR_maxBlockSize_invalid;
}
} else {
(*lz4fWrite)->maxWriteSize = 64 * 1024;
}
static LZ4F_errorCode_t writeHeader(LZ4_writeFile_t* writeFile,
FILE* fp,
const LZ4F_preferences_t* prefsPtr)
{
LZ4_byte headerBuf[LZ4F_HEADER_SIZE_MAX];
(*lz4fWrite)->dstBufMaxSize = LZ4F_compressBound((*lz4fWrite)->maxWriteSize, prefsPtr);
(*lz4fWrite)->dstBuf = (LZ4_byte*)malloc((*lz4fWrite)->dstBufMaxSize);
if ((*lz4fWrite)->dstBuf == NULL) {
free(*lz4fWrite);
return -LZ4F_ERROR_allocation_failed;
/* Generate header */
LZ4F_errorCode_t const headerSize = LZ4F_compressBegin(writeFile->cctxPtr,
headerBuf, LZ4F_HEADER_SIZE_MAX, prefsPtr);
if (LZ4F_isError(headerSize)) {
return headerSize;
}
ret = LZ4F_createCompressionContext(&(*lz4fWrite)->cctxPtr, LZ4F_getVersion());
if (LZ4F_isError(ret)) {
free((*lz4fWrite)->dstBuf);
free(*lz4fWrite);
return ret;
/* Write header to file */
if (headerSize != fwrite(headerBuf, 1, headerSize, fp)) {
RETURN_ERROR(io_write);
}
ret = LZ4F_compressBegin((*lz4fWrite)->cctxPtr, buf, LZ4F_HEADER_SIZE_MAX, prefsPtr);
if (LZ4F_isError(ret)) {
LZ4F_freeCompressionContext((*lz4fWrite)->cctxPtr);
free((*lz4fWrite)->dstBuf);
free(*lz4fWrite);
return ret;
return LZ4F_OK_NoError;
}
LZ4F_errorCode_t LZ4F_writeOpen(LZ4_writeFile_t** lz4fWrite, FILE* fp, const LZ4F_preferences_t* prefsPtr)
{
LZ4_writeFile_t* writeFile;
size_t blockSize;
if (fp == NULL || lz4fWrite == NULL)
RETURN_ERROR(parameter_null);
/* Validate block size */
{ LZ4F_blockSizeID_t const blockSizeID = prefsPtr ? prefsPtr->frameInfo.blockSizeID : LZ4F_default;
blockSize = LZ4F_getBlockSize(blockSizeID);
if (blockSize == 0) {
RETURN_ERROR(maxBlockSize_invalid);
} }
/* Allocate write file structure */
writeFile = (LZ4_writeFile_t*)calloc(1, sizeof(LZ4_writeFile_t));
if (writeFile == NULL) {
RETURN_ERROR(allocation_failed);
}
writeFile->fp = fp;
writeFile->errCode = LZ4F_OK_NoError;
writeFile->maxWriteSize = blockSize;
if (ret != fwrite(buf, 1, ret, fp)) {
LZ4F_freeCompressionContext((*lz4fWrite)->cctxPtr);
free((*lz4fWrite)->dstBuf);
free(*lz4fWrite);
return -LZ4F_ERROR_GENERIC;
/* Calculate and allocate destination buffer */
writeFile->dstBufMaxSize = LZ4F_compressBound(0, prefsPtr);
writeFile->dstBuf = (LZ4_byte*)malloc(writeFile->dstBufMaxSize);
if (writeFile->dstBuf == NULL) {
freeAndNullWriteFile(&writeFile);
RETURN_ERROR(allocation_failed);
}
(*lz4fWrite)->fp = fp;
(*lz4fWrite)->errCode = LZ4F_OK_NoError;
/* Initialize compression context */
{ LZ4F_errorCode_t const status = LZ4F_createCompressionContext(&writeFile->cctxPtr, LZ4F_VERSION);
if (LZ4F_isError(status)) {
freeAndNullWriteFile(lz4fWrite);
return status;
} }
/* Write header to file */
{ LZ4F_errorCode_t const writeStatus = writeHeader(writeFile, fp, prefsPtr);
if (LZ4F_isError(writeStatus)) {
freeAndNullWriteFile(&writeFile);
return writeStatus;
} }
*lz4fWrite = writeFile;
return LZ4F_OK_NoError;
}
size_t LZ4F_write(LZ4_writeFile_t* lz4fWrite, void* buf, size_t size)
size_t LZ4F_write(LZ4_writeFile_t* lz4fWrite, const void* buf, size_t size)
{
LZ4_byte* p = (LZ4_byte*)buf;
size_t remain = size;
size_t chunk;
size_t ret;
const LZ4_byte* p = (const LZ4_byte*)buf;
size_t remainingBytes = size;
/* Validate parameters */
if (lz4fWrite == NULL || buf == NULL)
return -LZ4F_ERROR_GENERIC;
while (remain) {
if (remain > lz4fWrite->maxWriteSize)
chunk = lz4fWrite->maxWriteSize;
else
chunk = remain;
RETURN_ERROR(parameter_null);
ret = LZ4F_compressUpdate(lz4fWrite->cctxPtr,
while (remainingBytes) {
size_t const chunkSize = (remainingBytes > lz4fWrite->maxWriteSize) ? lz4fWrite->maxWriteSize : remainingBytes;
/* Compress and write chunk */
size_t cSize = LZ4F_compressUpdate(lz4fWrite->cctxPtr,
lz4fWrite->dstBuf, lz4fWrite->dstBufMaxSize,
p, chunk,
p, chunkSize,
NULL);
if (LZ4F_isError(ret)) {
lz4fWrite->errCode = ret;
return ret;
if (LZ4F_isError(cSize)) {
lz4fWrite->errCode = cSize;
return cSize;
}
if(ret != fwrite(lz4fWrite->dstBuf, 1, ret, lz4fWrite->fp)) {
lz4fWrite->errCode = -LZ4F_ERROR_GENERIC;
return -LZ4F_ERROR_GENERIC;
if (cSize != fwrite(lz4fWrite->dstBuf, 1, cSize, lz4fWrite->fp)) {
lz4fWrite->errCode = returnErrorCode(LZ4F_ERROR_io_write);
RETURN_ERROR(io_write);
}
p += chunk;
remain -= chunk;
/* Update positions */
p += chunkSize;
remainingBytes -= chunkSize;
}

@@ -294,4 +346,5 @@

if (lz4fWrite == NULL)
return -LZ4F_ERROR_GENERIC;
if (lz4fWrite == NULL) {
RETURN_ERROR(parameter_null);
}

@@ -303,15 +356,13 @@ if (lz4fWrite->errCode == LZ4F_OK_NoError) {

if (LZ4F_isError(ret)) {
goto out;
goto cleanup;
}
if (ret != fwrite(lz4fWrite->dstBuf, 1, ret, lz4fWrite->fp)) {
ret = -LZ4F_ERROR_GENERIC;
ret = returnErrorCode(LZ4F_ERROR_io_write);
}
}
out:
LZ4F_freeCompressionContext(lz4fWrite->cctxPtr);
free(lz4fWrite->dstBuf);
free(lz4fWrite);
cleanup:
freeWriteFileResources(lz4fWrite);
return ret;
}
/*
LZ4 file library
Header File
Copyright (C) 2022, Xiaomi Inc.
Copyright (c) Yann Collet and LZ4 contributors. All rights reserved.
BSD 2-Clause License (http://www.opensource.org/licenses/bsd-license.php)

@@ -41,3 +42,3 @@

#include <stdio.h>
#include <stdio.h> /* FILE* */
#include "lz4frame_static.h"

@@ -48,6 +49,17 @@

/*! LZ4F_readOpen() :
* Set read lz4file handle.
* `lz4f` will set a lz4file handle.
* `fp` must be the return value of the lz4 file opened by fopen.
/** LZ4 File Decompression **/
/**
* Opens an LZ4 file for reading.
* Note that the FILE* handle @p fp must be opened in binary mode.
*
* @param lz4fRead Pointer to receive the read file handle.
* It is an OUT parameter, so its initial value is ignored and will be overwritten.
* Its value on exit is only valid if the function returns LZ4F_OK_NoError.
* @param fp FILE* positioned at start of LZ4 file (binary mode).
*
* @return LZ4F_OK_NoError on success, or error code on failure.
* Can be tested with LZ4F_isError().
*
* @note Must be closed with LZ4F_readClose() when done.
*/

@@ -70,6 +82,17 @@ LZ4FLIB_STATIC_API LZ4F_errorCode_t LZ4F_readOpen(LZ4_readFile_t** lz4fRead, FILE* fp);

/*! LZ4F_writeOpen() :
* Set write lz4file handle.
* `lz4f` will set a lz4file handle.
* `fp` must be the return value of the lz4 file opened by fopen.
/** LZ4 File Decompression **/
/**
* Opens an LZ4 file for writing.
* Note that the FILE* handle @p fp must be opened in write binary mode.
*
* @param lz4fWrite Pointer to receive the write file handle.
* It is an OUT parameter, so its initial value is ignored and will be overwritten.
* Its value on exit is only valid if the function returns LZ4F_OK_NoError.
* @param fp FILE* positioned at start of LZ4 file (binary mode).
*
* @return LZ4F_OK_NoError on success, or error code on failure.
* Can be tested with LZ4F_isError().
*
* @note Must be closed with LZ4F_writeClose() when done.
*/

@@ -84,3 +107,3 @@ LZ4FLIB_STATIC_API LZ4F_errorCode_t LZ4F_writeOpen(LZ4_writeFile_t** lz4fWrite, FILE* fp, const LZ4F_preferences_t* prefsPtr);

*/
LZ4FLIB_STATIC_API size_t LZ4F_write(LZ4_writeFile_t* lz4fWrite, void* buf, size_t size);
LZ4FLIB_STATIC_API size_t LZ4F_write(LZ4_writeFile_t* lz4fWrite, const void* buf, size_t size);

@@ -87,0 +110,0 @@ /*! LZ4F_writeClose() :

/*
LZ4 auto-framing library
Header File for static linking only
Copyright (C) 2011-2020, Yann Collet.
Copyright (c) Yann Collet. All rights reserved.

@@ -6,0 +6,0 @@ BSD 2-Clause License (http://www.opensource.org/licenses/bsd-license.php)

/*
LZ4F - LZ4-Frame library
Header File
Copyright (C) 2011-2020, Yann Collet.
Copyright (c) Yann Collet. All rights reserved.
BSD 2-Clause License (http://www.opensource.org/licenses/bsd-license.php)

@@ -176,12 +177,12 @@

typedef struct {
LZ4F_blockSizeID_t blockSizeID; /* max64KB, max256KB, max1MB, max4MB; 0 == default */
LZ4F_blockMode_t blockMode; /* LZ4F_blockLinked, LZ4F_blockIndependent; 0 == default */
LZ4F_contentChecksum_t contentChecksumFlag; /* 1: frame terminated with 32-bit checksum of decompressed data; 0: disabled (default) */
LZ4F_blockSizeID_t blockSizeID; /* max64KB, max256KB, max1MB, max4MB; 0 == default (LZ4F_max64KB) */
LZ4F_blockMode_t blockMode; /* LZ4F_blockLinked, LZ4F_blockIndependent; 0 == default (LZ4F_blockLinked) */
LZ4F_contentChecksum_t contentChecksumFlag; /* 1: add a 32-bit checksum of frame's decompressed data; 0 == default (disabled) */
LZ4F_frameType_t frameType; /* read-only field : LZ4F_frame or LZ4F_skippableFrame */
unsigned long long contentSize; /* Size of uncompressed content ; 0 == unknown */
unsigned dictID; /* Dictionary ID, sent by compressor to help decoder select correct dictionary; 0 == no dictID provided */
LZ4F_blockChecksum_t blockChecksumFlag; /* 1: each block followed by a checksum of block's compressed data; 0: disabled (default) */
LZ4F_blockChecksum_t blockChecksumFlag; /* 1: each block followed by a checksum of block's compressed data; 0 == default (disabled) */
} LZ4F_frameInfo_t;
#define LZ4F_INIT_FRAMEINFO { LZ4F_default, LZ4F_blockLinked, LZ4F_noContentChecksum, LZ4F_frame, 0ULL, 0U, LZ4F_noBlockChecksum } /* v1.8.3+ */
#define LZ4F_INIT_FRAMEINFO { LZ4F_max64KB, LZ4F_blockLinked, LZ4F_noContentChecksum, LZ4F_frame, 0ULL, 0U, LZ4F_noBlockChecksum } /* v1.8.3+ */

@@ -208,3 +209,22 @@ /*! LZ4F_preferences_t :

LZ4FLIB_API int LZ4F_compressionLevel_max(void); /* v1.8.0+ */
/*! LZ4F_compressFrame() :
* Compress srcBuffer content into an LZ4-compressed frame.
* It's a one shot operation, all input content is consumed, and all output is generated.
*
* Note : it's a stateless operation (no LZ4F_cctx state needed).
* In order to reduce load on the allocator, LZ4F_compressFrame(), by default,
* uses the stack to allocate space for the compression state and some table.
* If this usage of the stack is too much for your application,
* consider compiling `lz4frame.c` with compile-time macro LZ4F_HEAPMODE set to 1 instead.
* All state allocations will use the Heap.
* It also means each invocation of LZ4F_compressFrame() will trigger several internal alloc/free invocations.
*
* @dstCapacity MUST be >= LZ4F_compressFrameBound(srcSize, preferencesPtr).
* @preferencesPtr is optional : one can provide NULL, in which case all preferences are set to default.
* @return : number of bytes written into dstBuffer.
* or an error code if it fails (can be tested using LZ4F_isError())
*/
LZ4FLIB_API size_t LZ4F_compressFrame(void* dstBuffer, size_t dstCapacity,
const void* srcBuffer, size_t srcSize,
const LZ4F_preferences_t* preferencesPtr);

@@ -219,12 +239,7 @@ /*! LZ4F_compressFrameBound() :

/*! LZ4F_compressFrame() :
* Compress an entire srcBuffer into a valid LZ4 frame.
* dstCapacity MUST be >= LZ4F_compressFrameBound(srcSize, preferencesPtr).
* The LZ4F_preferences_t structure is optional : you can provide NULL as argument. All preferences will be set to default.
* @return : number of bytes written into dstBuffer.
* or an error code if it fails (can be tested using LZ4F_isError())
/*! LZ4F_compressionLevel_max() :
* @return maximum allowed compression level (currently: 12)
*/
LZ4FLIB_API size_t LZ4F_compressFrame(void* dstBuffer, size_t dstCapacity,
const void* srcBuffer, size_t srcSize,
const LZ4F_preferences_t* preferencesPtr);
LZ4FLIB_API int LZ4F_compressionLevel_max(void); /* v1.8.0+ */

@@ -281,6 +296,9 @@

/* Size in bytes of the endmark. */
#define LZ4F_ENDMARK_SIZE 4
/*! LZ4F_compressBegin() :
* will write the frame header into dstBuffer.
* dstCapacity must be >= LZ4F_HEADER_SIZE_MAX bytes.
* `prefsPtr` is optional : you can provide NULL as argument, all preferences will then be set to default.
* `prefsPtr` is optional : NULL can be provided to set all preferences to default.
* @return : number of bytes written into dstBuffer for the header

@@ -362,4 +380,5 @@ * or an error code (which can be tested using LZ4F_isError())

typedef struct {
unsigned stableDst; /* pledges that last 64KB decompressed data will remain available unmodified between invocations.
* This optimization skips storage operations in tmp buffers. */
unsigned stableDst; /* pledges that last 64KB decompressed data is present right before @dstBuffer pointer.
* This optimization skips internal storage operations.
* Once set, this pledge must remain valid up to the end of current frame. */
unsigned skipChecksums; /* disable checksum calculation and verification, even when one is present in frame, to save CPU time.

@@ -455,32 +474,48 @@ * Setting this option to 1 once disables all checksums for the rest of the frame. */

/*! LZ4F_decompress() :
* Call this function repetitively to regenerate data compressed in `srcBuffer`.
/**
* @brief Incrementally decompresses an LZ4 frame into user-provided buffers.
*
* The function requires a valid dctx state.
* It will read up to *srcSizePtr bytes from srcBuffer,
* and decompress data into dstBuffer, of capacity *dstSizePtr.
* Call repeatedly until the return value is 0 (frame fully decoded) or an error is reported.
* On each call, the function consumes up to *srcSizePtr bytes from @p srcBuffer and
* produces up to *dstSizePtr bytes into @p dstBuffer. It updates both size pointers with
* the actual number of bytes consumed/produced. There is no separate flush step.
*
* The nb of bytes consumed from srcBuffer will be written into *srcSizePtr (necessarily <= original value).
* The nb of bytes decompressed into dstBuffer will be written into *dstSizePtr (necessarily <= original value).
* Typical loop:
* - Provide whatever input you have and an available output buffer.
* - Read how much input was consumed and how much output was produced.
* - Use the returned value as a hint for how many source bytes are ideal next time.
*
* The function does not necessarily read all input bytes, so always check value in *srcSizePtr.
* Unconsumed source data must be presented again in subsequent invocations.
* @param[in] dctx A valid decompression context created by LZ4F_createDecompressionContext().
* @param[out] dstBuffer Destination buffer for decompressed bytes. May change between calls.
* @param[in,out] dstSizePtr In: capacity of @p dstBuffer in bytes. Out: number of bytes written (<= input value).
* @param[in] srcBuffer Source buffer containing (more) compressed data. May point to the middle of a larger buffer.
* @param[in,out] srcSizePtr In: number of available bytes in @p srcBuffer. Out: number of bytes consumed (<= input value).
* @param[in] optionsPtr Optional decompression options; pass NULL for defaults.
*
* `dstBuffer` can freely change between each consecutive function invocation.
* `dstBuffer` content will be overwritten.
* @return See @retval cases.
* @retval >0 Hint (in bytes) for how many source bytes are ideal to provide on the next call.
* This also indicates the current frame is not yet complete: the decompressor
* expects more input, or may require additional output space to make progress.
* User can always pass any amount of input; this value is only a performance hint.
* @retval 0 The current frame is fully decoded. If *srcSizePtr is less than the provided value,
* the unconsumed tail is the start of another frame (if any).
* @retval error An error code; test with LZ4F_isError(ret). After an error, dctx is not
* resumable: call LZ4F_resetDecompressionContext() before reusing it.
*
* @return : an hint of how many `srcSize` bytes LZ4F_decompress() expects for next call.
* Schematically, it's the size of the current (or remaining) compressed block + header of next block.
* Respecting the hint provides some small speed benefit, because it skips intermediate buffers.
* This is just a hint though, it's always possible to provide any srcSize.
* @pre @p dctx is a valid state created by LZ4F_createDecompressionContext().
* @post *srcSizePtr and *dstSizePtr are updated with the actual bytes consumed/produced.
* @p dstBuffer contents in [0, *dstSizePtr) are valid decompressed data.
*
* When a frame is fully decoded, @return will be 0 (no more data expected).
* When provided with more bytes than necessary to decode a frame,
* LZ4F_decompress() will stop reading exactly at end of current frame, and @return 0.
* @note The function may not consume all provided input on each call. Always check *srcSizePtr.
* Present any unconsumed source bytes again on the next call.
* @note @p dstBuffer content is overwritten; it does not need to be stable across calls.
* @note After finishing a frame (return==0), you may immediately start feeding the next frame
* into the same @p dctx (optionally, one can use LZ4F_resetDecompressionContext()).
*
* If decompression failed, @return is an error code, which can be tested using LZ4F_isError().
* After a decompression error, the `dctx` context is not resumable.
* Use LZ4F_resetDecompressionContext() to return to clean state.
* @warning If you called LZ4F_getFrameInfo() beforehand, you must advance @p srcBuffer and
* decrease *srcSizePtr by the number of bytes it consumed (the frame header). Failing
* to do so can cause decompression failure or, worse, silent corruption.
*
* After a frame is fully decoded, dctx can be used again to decompress another frame.
* @see LZ4F_getFrameInfo(), LZ4F_isError(), LZ4F_resetDecompressionContext(),
* LZ4F_createDecompressionContext(), LZ4F_freeDecompressionContext()
*/

@@ -502,3 +537,106 @@ LZ4FLIB_API size_t

/**********************************
* Dictionary compression API
*********************************/
/* A Dictionary is useful for the compression of small messages (KB range).
* It dramatically improves compression efficiency.
*
* LZ4 can ingest any input as dictionary, though only the last 64 KB are useful.
* Better results are generally achieved by using Zstandard's Dictionary Builder
* to generate a high-quality dictionary from a set of samples.
*
* The same dictionary will have to be used on the decompression side
* for decoding to be successful.
* To help identify the correct dictionary at decoding stage,
* the frame header allows optional embedding of a dictID field.
*/
/*! LZ4F_compressBegin_usingDict() : stable since v1.10
* Inits dictionary compression streaming, and writes the frame header into dstBuffer.
* @dstCapacity must be >= LZ4F_HEADER_SIZE_MAX bytes.
* @prefsPtr is optional : one may provide NULL as argument,
* however, it's the only way to provide dictID in the frame header.
* @dictBuffer must outlive the compression session.
* @return : number of bytes written into dstBuffer for the header,
* or an error code (which can be tested using LZ4F_isError())
* NOTE: The LZ4Frame spec allows each independent block to be compressed with the dictionary,
* but this entry supports a more limited scenario, where only the first block uses the dictionary.
* This is still useful for small data, which only need one block anyway.
* For larger inputs, one may be more interested in LZ4F_compressFrame_usingCDict() below.
*/
LZ4FLIB_API size_t
LZ4F_compressBegin_usingDict(LZ4F_cctx* cctx,
void* dstBuffer, size_t dstCapacity,
const void* dictBuffer, size_t dictSize,
const LZ4F_preferences_t* prefsPtr);
/*! LZ4F_decompress_usingDict() : stable since v1.10
* Same as LZ4F_decompress(), using a predefined dictionary.
* Dictionary is used "in place", without any preprocessing.
** It must remain accessible throughout the entire frame decoding. */
LZ4FLIB_API size_t
LZ4F_decompress_usingDict(LZ4F_dctx* dctxPtr,
void* dstBuffer, size_t* dstSizePtr,
const void* srcBuffer, size_t* srcSizePtr,
const void* dict, size_t dictSize,
const LZ4F_decompressOptions_t* decompressOptionsPtr);
/*****************************************
* Bulk processing dictionary compression
*****************************************/
/* Loading a dictionary has a cost, since it involves construction of tables.
* The Bulk processing dictionary API makes it possible to share this cost
* over an arbitrary number of compression jobs, even concurrently,
* markedly improving compression latency for these cases.
*
* Note that there is no corresponding bulk API for the decompression side,
* because dictionary does not carry any initialization cost for decompression.
* Use the regular LZ4F_decompress_usingDict() there.
*/
typedef struct LZ4F_CDict_s LZ4F_CDict;
/*! LZ4_createCDict() : stable since v1.10
* When compressing multiple messages / blocks using the same dictionary, it's recommended to initialize it just once.
* LZ4_createCDict() will create a digested dictionary, ready to start future compression operations without startup delay.
* LZ4_CDict can be created once and shared by multiple threads concurrently, since its usage is read-only.
* @dictBuffer can be released after LZ4_CDict creation, since its content is copied within CDict. */
LZ4FLIB_API LZ4F_CDict* LZ4F_createCDict(const void* dictBuffer, size_t dictSize);
LZ4FLIB_API void LZ4F_freeCDict(LZ4F_CDict* CDict);
/*! LZ4_compressFrame_usingCDict() : stable since v1.10
* Compress an entire srcBuffer into a valid LZ4 frame using a digested Dictionary.
* @cctx must point to a context created by LZ4F_createCompressionContext().
* If @cdict==NULL, compress without a dictionary.
* @dstBuffer MUST be >= LZ4F_compressFrameBound(srcSize, preferencesPtr).
* If this condition is not respected, function will fail (@return an errorCode).
* The LZ4F_preferences_t structure is optional : one may provide NULL as argument,
* but it's not recommended, as it's the only way to provide @dictID in the frame header.
* @return : number of bytes written into dstBuffer.
* or an error code if it fails (can be tested using LZ4F_isError())
* Note: for larger inputs generating multiple independent blocks,
* this entry point uses the dictionary for each block. */
LZ4FLIB_API size_t
LZ4F_compressFrame_usingCDict(LZ4F_cctx* cctx,
void* dst, size_t dstCapacity,
const void* src, size_t srcSize,
const LZ4F_CDict* cdict,
const LZ4F_preferences_t* preferencesPtr);
/*! LZ4F_compressBegin_usingCDict() : stable since v1.10
* Inits streaming dictionary compression, and writes the frame header into dstBuffer.
* @dstCapacity must be >= LZ4F_HEADER_SIZE_MAX bytes.
* @prefsPtr is optional : one may provide NULL as argument,
* note however that it's the only way to insert a @dictID in the frame header.
* @cdict must outlive the compression session.
* @return : number of bytes written into dstBuffer for the header,
* or an error code, which can be tested using LZ4F_isError(). */
LZ4FLIB_API size_t
LZ4F_compressBegin_usingCDict(LZ4F_cctx* cctx,
void* dstBuffer, size_t dstCapacity,
const LZ4F_CDict* cdict,
const LZ4F_preferences_t* prefsPtr);
#if defined (__cplusplus)

@@ -513,7 +651,4 @@ }

#if defined (__cplusplus)
extern "C" {
#endif
/* These declarations are not stable and may change in the future.
/* Note :
* The below declarations are not stable and may change in the future.
* They are therefore only safe to depend on

@@ -528,2 +663,7 @@ * when the caller is statically linked against the library.

*/
#if defined (__cplusplus)
extern "C" {
#endif
#ifdef LZ4F_PUBLISH_STATIC_FUNCTIONS

@@ -542,3 +682,3 @@ # define LZ4FLIB_STATIC_API LZ4FLIB_API

ITEM(ERROR_blockMode_invalid) \
ITEM(ERROR_contentChecksumFlag_invalid) \
ITEM(ERROR_parameter_invalid) \
ITEM(ERROR_compressionLevel_invalid) \

@@ -561,2 +701,4 @@ ITEM(ERROR_headerVersion_wrong) \

ITEM(ERROR_parameter_null) \
ITEM(ERROR_io_write) \
ITEM(ERROR_io_read) \
ITEM(ERROR_maxCode)

@@ -572,6 +714,10 @@

/**********************************
* Advanced compression operations
*********************************/
/*! LZ4F_getBlockSize() :
* Return, in scalar format (size_t),
* the maximum block size associated with blockSizeID.
* @return, in scalar format (size_t),
* the maximum block size associated with @blockSizeID,
* or an error code (can be tested using LZ4F_isError()) if @blockSizeID is invalid.
**/

@@ -581,3 +727,3 @@ LZ4FLIB_STATIC_API size_t LZ4F_getBlockSize(LZ4F_blockSizeID_t blockSizeID);

/*! LZ4F_uncompressedUpdate() :
* LZ4F_uncompressedUpdate() can be called repetitively to add as much data uncompressed data as necessary.
* LZ4F_uncompressedUpdate() can be called repetitively to add data stored as uncompressed blocks.
* Important rule: dstCapacity MUST be large enough to store the entire source buffer as

@@ -587,5 +733,5 @@ * no compression is done for this operation

* After an error, the state is left in a UB state, and must be re-initialized or freed.
* If previously a compressed block was written, buffered data is flushed
* If previously a compressed block was written, buffered data is flushed first,
* before appending uncompressed data is continued.
* This is only supported when LZ4F_blockIndependent is used
* This operation is only supported when LZ4F_blockIndependent is used.
* `cOptPtr` is optional : NULL can be provided, in which case all options are set to default.

@@ -602,78 +748,6 @@ * @return : number of bytes written into `dstBuffer` (it can be zero, meaning input data was just buffered).

/**********************************
* Bulk processing dictionary API
* Custom memory allocation
*********************************/
/* A Dictionary is useful for the compression of small messages (KB range).
* It dramatically improves compression efficiency.
*
* LZ4 can ingest any input as dictionary, though only the last 64 KB are useful.
* Best results are generally achieved by using Zstandard's Dictionary Builder
* to generate a high-quality dictionary from a set of samples.
*
* Loading a dictionary has a cost, since it involves construction of tables.
* The Bulk processing dictionary API makes it possible to share this cost
* over an arbitrary number of compression jobs, even concurrently,
* markedly improving compression latency for these cases.
*
* The same dictionary will have to be used on the decompression side
* for decoding to be successful.
* To help identify the correct dictionary at decoding stage,
* the frame header allows optional embedding of a dictID field.
*/
typedef struct LZ4F_CDict_s LZ4F_CDict;
/*! LZ4_createCDict() :
* When compressing multiple messages / blocks using the same dictionary, it's recommended to load it just once.
* LZ4_createCDict() will create a digested dictionary, ready to start future compression operations without startup delay.
* LZ4_CDict can be created once and shared by multiple threads concurrently, since its usage is read-only.
* `dictBuffer` can be released after LZ4_CDict creation, since its content is copied within CDict */
LZ4FLIB_STATIC_API LZ4F_CDict* LZ4F_createCDict(const void* dictBuffer, size_t dictSize);
LZ4FLIB_STATIC_API void LZ4F_freeCDict(LZ4F_CDict* CDict);
/*! LZ4_compressFrame_usingCDict() :
* Compress an entire srcBuffer into a valid LZ4 frame using a digested Dictionary.
* cctx must point to a context created by LZ4F_createCompressionContext().
* If cdict==NULL, compress without a dictionary.
* dstBuffer MUST be >= LZ4F_compressFrameBound(srcSize, preferencesPtr).
* If this condition is not respected, function will fail (@return an errorCode).
* The LZ4F_preferences_t structure is optional : you may provide NULL as argument,
* but it's not recommended, as it's the only way to provide dictID in the frame header.
* @return : number of bytes written into dstBuffer.
* or an error code if it fails (can be tested using LZ4F_isError()) */
LZ4FLIB_STATIC_API size_t
LZ4F_compressFrame_usingCDict(LZ4F_cctx* cctx,
void* dst, size_t dstCapacity,
const void* src, size_t srcSize,
const LZ4F_CDict* cdict,
const LZ4F_preferences_t* preferencesPtr);
/*! LZ4F_compressBegin_usingCDict() :
* Inits streaming dictionary compression, and writes the frame header into dstBuffer.
* dstCapacity must be >= LZ4F_HEADER_SIZE_MAX bytes.
* `prefsPtr` is optional : you may provide NULL as argument,
* however, it's the only way to provide dictID in the frame header.
* @return : number of bytes written into dstBuffer for the header,
* or an error code (which can be tested using LZ4F_isError()) */
LZ4FLIB_STATIC_API size_t
LZ4F_compressBegin_usingCDict(LZ4F_cctx* cctx,
void* dstBuffer, size_t dstCapacity,
const LZ4F_CDict* cdict,
const LZ4F_preferences_t* prefsPtr);
/*! LZ4F_decompress_usingDict() :
* Same as LZ4F_decompress(), using a predefined dictionary.
* Dictionary is used "in place", without any preprocessing.
** It must remain accessible throughout the entire frame decoding. */
LZ4FLIB_STATIC_API size_t
LZ4F_decompress_usingDict(LZ4F_dctx* dctxPtr,
void* dstBuffer, size_t* dstSizePtr,
const void* srcBuffer, size_t* srcSizePtr,
const void* dict, size_t dictSize,
const LZ4F_decompressOptions_t* decompressOptionsPtr);
/*! Custom memory allocation :
/*! Custom memory allocation : v1.9.4+
* These prototypes make it possible to pass custom allocation/free functions.

@@ -702,2 +776,7 @@ * LZ4F_customMem is provided at state creation time, using LZ4F_create*_advanced() listed below.

/*! Context size inspection : v1.10.1+
* These functions return the total memory footprint of the provided context.
*/
LZ4FLIB_STATIC_API size_t LZ4F_cctx_size(const LZ4F_cctx* cctx);
LZ4FLIB_STATIC_API size_t LZ4F_dctx_size(const LZ4F_dctx* dctx);

@@ -704,0 +783,0 @@ #if defined (__cplusplus)

/*
LZ4 HC - High Compression Mode of LZ4
Header File
Copyright (C) 2011-2020, Yann Collet.
Copyright (c) Yann Collet. All rights reserved.
BSD 2-Clause License (http://www.opensource.org/licenses/bsd-license.php)

@@ -47,3 +47,3 @@

/* --- Useful constants --- */
#define LZ4HC_CLEVEL_MIN 3
#define LZ4HC_CLEVEL_MIN 2
#define LZ4HC_CLEVEL_DEFAULT 9

@@ -130,2 +130,4 @@ #define LZ4HC_CLEVEL_OPT_MIN 10

using LZ4_loadDictHC() (Optional).
Note: In order for LZ4_loadDictHC() to create the correct data structure,
it is essential to set the compression level _before_ loading the dictionary.

@@ -140,3 +142,3 @@ Invoke LZ4_compress_HC_continue() to compress each successive block.

'dst' buffer should be sized to handle worst case scenarios
@dst buffer should be sized to handle worst case scenarios
(see LZ4_compressBound(), it ensures compression success).

@@ -146,3 +148,3 @@ In case of failure, the API does not guarantee recovery,

To ensure compression success
whenever `dst` buffer size cannot be made >= LZ4_compressBound(),
whenever @dst buffer size cannot be made >= LZ4_compressBound(),
consider using LZ4_compress_HC_continue_destSize().

@@ -183,3 +185,31 @@

/*! LZ4_attach_HC_dictionary() : stable since v1.10.0
* This API allows for the efficient re-use of a static dictionary many times.
*
* Rather than re-loading the dictionary buffer into a working context before
* each compression, or copying a pre-loaded dictionary's LZ4_streamHC_t into a
* working LZ4_streamHC_t, this function introduces a no-copy setup mechanism,
* in which the working stream references the dictionary stream in-place.
*
* Several assumptions are made about the state of the dictionary stream.
* Currently, only streams which have been prepared by LZ4_loadDictHC() should
* be expected to work.
*
* Alternatively, the provided dictionary stream pointer may be NULL, in which
* case any existing dictionary stream is unset.
*
* A dictionary should only be attached to a stream without any history (i.e.,
* a stream that has just been reset).
*
* The dictionary will remain attached to the working stream only for the
* current stream session. Calls to LZ4_resetStreamHC(_fast) will remove the
* dictionary context association from the working stream. The dictionary
* stream (and source buffer) must remain in-place / accessible / unchanged
* through the lifetime of the stream session.
*/
LZ4LIB_API void
LZ4_attach_HC_dictionary(LZ4_streamHC_t* working_stream,
const LZ4_streamHC_t* dictionary_stream);
/*^**********************************************

@@ -212,14 +242,14 @@ * !!!!!! STATIC LINKING ONLY !!!!!!

{
LZ4_u32 hashTable[LZ4HC_HASHTABLESIZE];
LZ4_u16 chainTable[LZ4HC_MAXD];
const LZ4_byte* end; /* next block here to continue on current prefix */
LZ4_u32 hashTable[LZ4HC_HASHTABLESIZE];
LZ4_u16 chainTable[LZ4HC_MAXD];
const LZ4_byte* end; /* next block here to continue on current prefix */
const LZ4_byte* prefixStart; /* Indexes relative to this position */
const LZ4_byte* dictStart; /* alternate reference for extDict */
LZ4_u32 dictLimit; /* below that point, need extDict */
LZ4_u32 lowLimit; /* below that point, no more dict */
LZ4_u32 nextToUpdate; /* index from which to continue dictionary update */
short compressionLevel;
LZ4_i8 favorDecSpeed; /* favor decompression speed if this flag set,
otherwise, favor compression ratio */
LZ4_i8 dirty; /* stream has to be fully reset if this flag is set */
LZ4_u32 dictLimit; /* below that point, need extDict */
LZ4_u32 lowLimit; /* below that point, no more history */
LZ4_u32 nextToUpdate; /* index from which to continue dictionary update */
short compressionLevel;
LZ4_i8 favorDecSpeed; /* favor decompression speed if this flag set,
otherwise, favor compression ratio */
LZ4_i8 dirty; /* stream has to be fully reset if this flag is set */
const LZ4HC_CCtx_internal* dictCtx;

@@ -385,31 +415,2 @@ };

/*! LZ4_attach_HC_dictionary() :
* This is an experimental API that allows for the efficient use of a
* static dictionary many times.
*
* Rather than re-loading the dictionary buffer into a working context before
* each compression, or copying a pre-loaded dictionary's LZ4_streamHC_t into a
* working LZ4_streamHC_t, this function introduces a no-copy setup mechanism,
* in which the working stream references the dictionary stream in-place.
*
* Several assumptions are made about the state of the dictionary stream.
* Currently, only streams which have been prepared by LZ4_loadDictHC() should
* be expected to work.
*
* Alternatively, the provided dictionary stream pointer may be NULL, in which
* case any existing dictionary stream is unset.
*
* A dictionary should only be attached to a stream without any history (i.e.,
* a stream that has just been reset).
*
* The dictionary will remain attached to the working stream only for the
* current stream session. Calls to LZ4_resetStreamHC(_fast) will remove the
* dictionary context association from the working stream. The dictionary
* stream (and source buffer) must remain in-place / accessible / unchanged
* through the lifetime of the stream session.
*/
LZ4LIB_STATIC_API void LZ4_attach_HC_dictionary(
LZ4_streamHC_t *working_stream,
const LZ4_streamHC_t *dictionary_stream);
#if defined (__cplusplus)

@@ -416,0 +417,0 @@ }

# ################################################################
# LZ4 library - Makefile
# Copyright (C) Yann Collet 2011-2020
# Copyright (C) Yann Collet 2011-2023
# All rights reserved.

@@ -34,8 +34,8 @@ #

# ################################################################
SED = sed
SED ?= sed
# Version numbers
LIBVER_MAJOR_SCRIPT:=`$(SED) -n '/define LZ4_VERSION_MAJOR/s/.*[[:blank:]]\([0-9][0-9]*\).*/\1/p' < ./lz4.h`
LIBVER_MINOR_SCRIPT:=`$(SED) -n '/define LZ4_VERSION_MINOR/s/.*[[:blank:]]\([0-9][0-9]*\).*/\1/p' < ./lz4.h`
LIBVER_PATCH_SCRIPT:=`$(SED) -n '/define LZ4_VERSION_RELEASE/s/.*[[:blank:]]\([0-9][0-9]*\).*/\1/p' < ./lz4.h`
LIBVER_MAJOR_SCRIPT:=`$(SED) -n '/define[[:blank:]][[:blank:]]*LZ4_VERSION_MAJOR/s/.*[[:blank:]]\([0-9][0-9]*\).*/\1/p' < ./lz4.h`
LIBVER_MINOR_SCRIPT:=`$(SED) -n '/define[[:blank:]][[:blank:]]*LZ4_VERSION_MINOR/s/.*[[:blank:]]\([0-9][0-9]*\).*/\1/p' < ./lz4.h`
LIBVER_PATCH_SCRIPT:=`$(SED) -n '/define[[:blank:]][[:blank:]]*LZ4_VERSION_RELEASE/s/.*[[:blank:]]\([0-9][0-9]*\).*/\1/p' < ./lz4.h`
LIBVER_SCRIPT:= $(LIBVER_MAJOR_SCRIPT).$(LIBVER_MINOR_SCRIPT).$(LIBVER_PATCH_SCRIPT)

@@ -51,14 +51,20 @@ LIBVER_MAJOR := $(shell echo $(LIBVER_MAJOR_SCRIPT))

CPPFLAGS+= -DXXH_NAMESPACE=LZ4_
CPPFLAGS+= $(MOREFLAGS)
CFLAGS ?= -O3
USERCFLAGS:= -O3 $(CFLAGS)
DEBUGFLAGS:= -Wall -Wextra -Wcast-qual -Wcast-align -Wshadow \
-Wswitch-enum -Wdeclaration-after-statement -Wstrict-prototypes \
-Wundef -Wpointer-arith -Wstrict-aliasing=1
CFLAGS += $(DEBUGFLAGS)
FLAGS = $(CFLAGS) $(CPPFLAGS) $(LDFLAGS)
CFLAGS = $(DEBUGFLAGS) $(USERCFLAGS)
ALLFLAGS = $(CFLAGS) $(CPPFLAGS) $(LDFLAGS)
SRCFILES := $(sort $(wildcard *.c))
OBJFILES = $(SRCFILES:.c=.o)
include ../Makefile.inc
include ../build/make/lz4defs.make
# default is defined as the first target in Makefile, hence before multiconf.make
.PHONY: default
default: lib-release
include ../build/make/multiconf.make
# OS X linker doesn't support -soname, and use different extension

@@ -70,18 +76,25 @@ # see : https://developer.apple.com/library/mac/documentation/DeveloperTools/Conceptual/DynamicLibraries/100-Articles/DynamicLibraryDesignGuidelines.html

SHARED_EXT_VER = $(LIBVER).$(SHARED_EXT)
SONAME_FLAGS = -install_name $(libdir)/liblz4.$(SHARED_EXT_MAJOR) -compatibility_version $(LIBVER_MAJOR) -current_version $(LIBVER)
SONAME_FLAGS = -install_name $(libdir)/liblz4.$(SHARED_EXT_MAJOR) -compatibility_version $(LIBVER_MAJOR) -current_version $(LIBVER) -dynamiclib
else
SONAME_FLAGS = -Wl,-soname=liblz4.$(SHARED_EXT).$(LIBVER_MAJOR)
SHARED_EXT = so
SHARED_EXT_MAJOR = $(SHARED_EXT).$(LIBVER_MAJOR)
SHARED_EXT_VER = $(SHARED_EXT).$(LIBVER)
ifeq ($(WINBASED),yes)
SHARED_EXT = dll
SHARED_EXT_VER = $(SHARED_EXT)
else # posix non-mac
SONAME_FLAGS = -Wl,-soname=liblz4.$(SHARED_EXT).$(LIBVER_MAJOR)
SHARED_EXT = so
SHARED_EXT_MAJOR = $(SHARED_EXT).$(LIBVER_MAJOR)
SHARED_EXT_VER = $(SHARED_EXT).$(LIBVER)
endif
# AIX linker doesn't support -soname, hence assigning nil string
ifeq ($(TARGET_OS), AIX)
SONAME_FLAGS =
endif
endif
.PHONY: default
default: lib-release
# silent mode by default; verbose can be triggered by V=1 or VERBOSE=1
$(V)$(VERBOSE).SILENT:
.PHONY:lib-release
lib-release: DEBUGFLAGS :=
lib-release: lib
lib-release: lib liblz4.pc

@@ -92,3 +105,3 @@ .PHONY: lib

.PHONY: all
all: lib
all: lib liblz4.pc

@@ -99,13 +112,13 @@ .PHONY: all32

liblz4.a: $(SRCFILES)
ifeq ($(BUILD_STATIC),yes) # can be disabled on command line
@echo compiling static library
$(COMPILE.c) $^
$(AR) rcs $@ *.o
liblz4.a:
ifeq ($(BUILD_STATIC),yes)
$(eval $(call static_library,liblz4.a,$(OBJFILES)))
endif
ifeq ($(WINBASED),yes)
CLEAN += $(liblz4-dll.rc)
liblz4-dll.rc: liblz4-dll.rc.in
@echo creating library resource
$(SED) -e 's|@LIBLZ4@|$(LIBLZ4)|' \
$(SED) -e 's|@LIBLZ4@|$(LIBLZ4_NAME)|' \
-e 's|@LIBVER_MAJOR@|$(LIBVER_MAJOR)|g' \

@@ -119,27 +132,43 @@ -e 's|@LIBVER_MINOR@|$(LIBVER_MINOR)|g' \

CLEAN += $(LIBLZ4) $(LIBLZ4_EXP)
$(LIBLZ4): $(SRCFILES) liblz4-dll.o
ifeq ($(BUILD_SHARED),yes)
@echo compiling dynamic library $(LIBVER)
$(CC) $(FLAGS) -DLZ4_DLL_EXPORT=1 -shared $^ -o dll/$@.dll -Wl,--out-implib,dll/$(LIBLZ4_EXP)
$(CC) $(ALLFLAGS) -DLZ4_DLL_EXPORT=1 -shared $^ $(LDLIBS) -o $@ -Wl,--out-implib,$(LIBLZ4_EXP)
endif
else # not windows
$(LIBLZ4): $(SRCFILES)
@echo compiling dynamic library $(LIBVER)
$(CC) $(FLAGS) -shared $^ -fPIC -fvisibility=hidden $(SONAME_FLAGS) -o $@
@echo creating versioned links
$(LN_SF) $@ liblz4.$(SHARED_EXT_MAJOR)
$(LN_SF) $@ liblz4.$(SHARED_EXT)
$(LIBLZ4): LDFLAGS += -fvisibility=hidden $(SONAME_FLAGS)
ifeq ($(BUILD_SHARED),yes)
$(eval $(call c_dynamic_library,$(LIBLZ4),$(OBJFILES),,echo "$(LIBLZ4) created"))
endif
endif
liblz4.$(SHARED_EXT_MAJOR): $(LIBLZ4)
$(LN_SF) $< $@
liblz4.$(SHARED_EXT): liblz4.$(SHARED_EXT_MAJOR)
$(LN_SF) $< $@
.PHONY: liblz4
liblz4: $(LIBLZ4)
liblz4: $(LIBLZ4) liblz4.$(SHARED_EXT_MAJOR) liblz4.$(SHARED_EXT)
CLEAN += liblz4.pc
liblz4.pc: liblz4.pc.in Makefile
@echo creating pkgconfig
$(SED) -e 's|@PREFIX@|$(prefix)|' \
-e 's|@LIBDIR@|$(libdir)|' \
-e 's|@INCLUDEDIR@|$(includedir)|' \
-e 's|@VERSION@|$(LIBVER)|' \
-e 's|=${prefix}/|=$${prefix}/|' \
$< >$@
.PHONY: clean
clean:
ifeq ($(WINBASED),yes)
$(RM) *.rc
endif
$(RM) core *.o liblz4.pc dll/$(LIBLZ4).dll dll/$(LIBLZ4_EXP)
$(RM) *.a *.$(SHARED_EXT) *.$(SHARED_EXT_MAJOR) *.$(SHARED_EXT_VER)
$(RM) $(CLEAN) core *.o *.a
$(RM) *.$(SHARED_EXT) *.$(SHARED_EXT_MAJOR) *.$(SHARED_EXT_VER)
$(RM) -r tmp*
@echo Cleaning library completed

@@ -178,13 +207,5 @@

liblz4.pc: liblz4.pc.in Makefile
@echo creating pkgconfig
$(SED) -e 's|@PREFIX@|$(prefix)|' \
-e 's|@LIBDIR@|$(libdir)|' \
-e 's|@INCLUDEDIR@|$(includedir)|' \
-e 's|@VERSION@|$(LIBVER)|' \
-e 's|=${prefix}/|=$${prefix}/|' \
$< >$@
.PHONY: install
install: lib liblz4.pc
$(INSTALL_DIR) $(DESTDIR)$(pkgconfigdir)/ $(DESTDIR)$(includedir)/ $(DESTDIR)$(libdir)/ $(DESTDIR)$(bindir)/
$(MAKE_DIR) $(DESTDIR)$(pkgconfigdir)/ $(DESTDIR)$(includedir)/ $(DESTDIR)$(libdir)/ $(DESTDIR)$(bindir)/
$(INSTALL_DATA) liblz4.pc $(DESTDIR)$(pkgconfigdir)/

@@ -195,2 +216,3 @@ @echo Installing libraries in $(DESTDIR)$(libdir)

$(INSTALL_DATA) lz4frame_static.h $(DESTDIR)$(includedir)/lz4frame_static.h
$(INSTALL_DATA) lz4file.h $(DESTDIR)$(includedir)/lz4file.h
endif

@@ -202,4 +224,4 @@ ifeq ($(BUILD_SHARED),yes)

ifeq ($(WINBASED),yes)
$(INSTALL_PROGRAM) dll/$(LIBLZ4).dll $(DESTDIR)$(bindir)
$(INSTALL_PROGRAM) dll/$(LIBLZ4_EXP) $(DESTDIR)$(libdir)
$(INSTALL_PROGRAM) $(LIBLZ4) $(DESTDIR)$(bindir)
$(INSTALL_PROGRAM) $(LIBLZ4_EXP) $(DESTDIR)$(libdir)
else

@@ -217,6 +239,7 @@ $(INSTALL_PROGRAM) liblz4.$(SHARED_EXT_VER) $(DESTDIR)$(libdir)

.PHONY: uninstall
uninstall:
$(RM) $(DESTDIR)$(pkgconfigdir)/liblz4.pc
ifeq (WINBASED,1)
$(RM) $(DESTDIR)$(bindir)/$(LIBLZ4).dll
ifeq (WINBASED,yes)
$(RM) $(DESTDIR)$(bindir)/$(LIBLZ4)
$(RM) $(DESTDIR)$(libdir)/$(LIBLZ4_EXP)

@@ -233,4 +256,5 @@ else

$(RM) $(DESTDIR)$(includedir)/lz4frame_static.h
$(RM) $(DESTDIR)$(includedir)/lz4file.h
@echo lz4 libraries successfully uninstalled
endif

@@ -20,3 +20,3 @@ LZ4 - Library Files

For more compression ratio at the cost of compression speed,
For better compression ratio at the cost of compression speed,
the High Compression variant called **lz4hc** is available.

@@ -104,3 +104,3 @@ Add files **`lz4hc.c`** and **`lz4hc.h`**.

- `LZ4_USER_MEMORY_FUNCTIONS` : replace calls to `<stdlib,h>`'s `malloc()`, `calloc()` and `free()`
- `LZ4_USER_MEMORY_FUNCTIONS` : replace calls to `<stdlib.h>`'s `malloc()`, `calloc()` and `free()`
by user-defined functions, which must be named `LZ4_malloc()`, `LZ4_calloc()` and `LZ4_free()`.

@@ -113,2 +113,8 @@ User functions must be available at link time.

- `LZ4_STATIC_LINKING_ONLY_ENDIANNESS_INDEPENDENT_OUTPUT` : experimental feature aimed at producing the same
compressed output on platforms of different endianness (i.e. little-endian and big-endian).
Output on little-endian platforms shall remain unchanged, while big-endian platforms will start producing
the same output as little-endian ones. This isn't expected to impact backward- and forward-compatibility
in any way.
- `LZ4_FREESTANDING` : by setting this build macro to 1,

@@ -121,4 +127,22 @@ LZ4/HC removes dependencies on the C standard library,

- `LZ4_HEAPMODE` : Select how stateless compression functions like `LZ4_compress_default()`
allocate memory for their hash table,
in memory stack (0:default, fastest), or in memory heap (1:requires malloc()).
- `LZ4HC_HEAPMODE` : Select how stateless HC compression functions like `LZ4_compress_HC()`
allocate memory for their workspace:
in stack (0), or in heap (1:default).
Since workspace is rather large, stack can be inconvenient, hence heap mode is recommended.
- `LZ4F_HEAPMODE` : selects how `LZ4F_compressFrame()` allocates the compression state,
either on stack (default, value 0) or using heap memory (value 1).
#### Makefile variables
The following `Makefile` variables can be selected to alter the profile of produced binaries :
- `BUILD_SHARED` : generate `liblz4` dynamic library (enabled by default)
- `BUILD_STATIC` : generate `liblz4` static library (enabled by default)
#### Amalgamation

@@ -125,0 +149,0 @@

@@ -123,3 +123,3 @@ /*

***************************************/
#ifdef _MSC_VER /* Visual Studio */
#if defined (_MSC_VER) && !defined (__clang__) /* MSVC */
# pragma warning(disable : 4127) /* disable: C4127: conditional expression is constant */

@@ -129,3 +129,3 @@ # define FORCE_INLINE static __forceinline

# if defined (__cplusplus) || defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L /* C99 */
# ifdef __GNUC__
# if defined (__GNUC__) || defined (__clang__)
# define FORCE_INLINE static inline __attribute__((always_inline))

@@ -218,3 +218,3 @@ # else

***************************************/
typedef enum { XXH_bigEndian=0, XXH_littleEndian=1 } XXH_endianess;
typedef enum { XXH_bigEndian=0, XXH_littleEndian=1 } XXH_endianness;

@@ -237,3 +237,3 @@ /* XXH_CPU_LITTLE_ENDIAN can be defined externally, for example on the compiler command line */

FORCE_INLINE U32 XXH_readLE32_align(const void* ptr, XXH_endianess endian, XXH_alignment align)
FORCE_INLINE U32 XXH_readLE32_align(const void* ptr, XXH_endianness endian, XXH_alignment align)
{

@@ -246,3 +246,3 @@ if (align==XXH_unaligned)

FORCE_INLINE U32 XXH_readLE32(const void* ptr, XXH_endianess endian)
FORCE_INLINE U32 XXH_readLE32(const void* ptr, XXH_endianness endian)
{

@@ -297,3 +297,3 @@ return XXH_readLE32_align(ptr, endian, XXH_unaligned);

XXH32_finalize(U32 h32, const void* ptr, size_t len,
XXH_endianess endian, XXH_alignment align)
XXH_endianness endian, XXH_alignment align)

@@ -359,3 +359,3 @@ {

XXH32_endian_align(const void* input, size_t len, U32 seed,
XXH_endianess endian, XXH_alignment align)
XXH_endianness endian, XXH_alignment align)
{

@@ -408,3 +408,3 @@ const BYTE* p = (const BYTE*)input;

#else
XXH_endianess endian_detected = (XXH_endianess)XXH_CPU_LITTLE_ENDIAN;
XXH_endianness endian_detected = (XXH_endianness)XXH_CPU_LITTLE_ENDIAN;

@@ -460,3 +460,3 @@ if (XXH_FORCE_ALIGN_CHECK) {

FORCE_INLINE XXH_errorcode
XXH32_update_endian(XXH32_state_t* state, const void* input, size_t len, XXH_endianess endian)
XXH32_update_endian(XXH32_state_t* state, const void* input, size_t len, XXH_endianness endian)
{

@@ -526,3 +526,3 @@ if (input==NULL)

{
XXH_endianess endian_detected = (XXH_endianess)XXH_CPU_LITTLE_ENDIAN;
XXH_endianness endian_detected = (XXH_endianness)XXH_CPU_LITTLE_ENDIAN;

@@ -537,3 +537,3 @@ if ((endian_detected==XXH_littleEndian) || XXH_FORCE_NATIVE_FORMAT)

FORCE_INLINE U32
XXH32_digest_endian (const XXH32_state_t* state, XXH_endianess endian)
XXH32_digest_endian (const XXH32_state_t* state, XXH_endianness endian)
{

@@ -559,3 +559,3 @@ U32 h32;

{
XXH_endianess endian_detected = (XXH_endianess)XXH_CPU_LITTLE_ENDIAN;
XXH_endianness endian_detected = (XXH_endianness)XXH_CPU_LITTLE_ENDIAN;

@@ -657,3 +657,3 @@ if ((endian_detected==XXH_littleEndian) || XXH_FORCE_NATIVE_FORMAT)

FORCE_INLINE U64 XXH_readLE64_align(const void* ptr, XXH_endianess endian, XXH_alignment align)
FORCE_INLINE U64 XXH_readLE64_align(const void* ptr, XXH_endianness endian, XXH_alignment align)
{

@@ -666,3 +666,3 @@ if (align==XXH_unaligned)

FORCE_INLINE U64 XXH_readLE64(const void* ptr, XXH_endianess endian)
FORCE_INLINE U64 XXH_readLE64(const void* ptr, XXH_endianness endian)
{

@@ -717,3 +717,3 @@ return XXH_readLE64_align(ptr, endian, XXH_unaligned);

XXH64_finalize(U64 h64, const void* ptr, size_t len,
XXH_endianess endian, XXH_alignment align)
XXH_endianness endian, XXH_alignment align)
{

@@ -827,3 +827,3 @@ const BYTE* p = (const BYTE*)ptr;

XXH64_endian_align(const void* input, size_t len, U64 seed,
XXH_endianess endian, XXH_alignment align)
XXH_endianness endian, XXH_alignment align)
{

@@ -880,3 +880,3 @@ const BYTE* p = (const BYTE*)input;

#else
XXH_endianess endian_detected = (XXH_endianess)XXH_CPU_LITTLE_ENDIAN;
XXH_endianness endian_detected = (XXH_endianness)XXH_CPU_LITTLE_ENDIAN;

@@ -929,3 +929,3 @@ if (XXH_FORCE_ALIGN_CHECK) {

FORCE_INLINE XXH_errorcode
XXH64_update_endian (XXH64_state_t* state, const void* input, size_t len, XXH_endianess endian)
XXH64_update_endian (XXH64_state_t* state, const void* input, size_t len, XXH_endianness endian)
{

@@ -991,3 +991,3 @@ if (input==NULL)

{
XXH_endianess endian_detected = (XXH_endianess)XXH_CPU_LITTLE_ENDIAN;
XXH_endianness endian_detected = (XXH_endianness)XXH_CPU_LITTLE_ENDIAN;

@@ -1000,3 +1000,3 @@ if ((endian_detected==XXH_littleEndian) || XXH_FORCE_NATIVE_FORMAT)

FORCE_INLINE U64 XXH64_digest_endian (const XXH64_state_t* state, XXH_endianess endian)
FORCE_INLINE U64 XXH64_digest_endian (const XXH64_state_t* state, XXH_endianness endian)
{

@@ -1027,3 +1027,3 @@ U64 h64;

{
XXH_endianess endian_detected = (XXH_endianess)XXH_CPU_LITTLE_ENDIAN;
XXH_endianness endian_detected = (XXH_endianness)XXH_CPU_LITTLE_ENDIAN;

@@ -1030,0 +1030,0 @@ if ((endian_detected==XXH_littleEndian) || XXH_FORCE_NATIVE_FORMAT)

@@ -363,2 +363,3 @@ import {

'saveStructures',
'useBigIntExtension',
'useFloat32',

@@ -365,0 +366,0 @@ 'useRecords',

{
"name": "lmdb",
"author": "Kris Zyp",
"version": "3.4.3",
"version": "3.4.4",
"description": "Simple, efficient, scalable, high-performance LMDB interface",

@@ -114,10 +114,10 @@ "license": "MIT",

"optionalDependencies": {
"@lmdb/lmdb-darwin-arm64": "3.4.3",
"@lmdb/lmdb-darwin-x64": "3.4.3",
"@lmdb/lmdb-linux-arm": "3.4.3",
"@lmdb/lmdb-linux-arm64": "3.4.3",
"@lmdb/lmdb-linux-x64": "3.4.3",
"@lmdb/lmdb-win32-arm64": "3.4.3",
"@lmdb/lmdb-win32-x64": "3.4.3"
"@lmdb/lmdb-darwin-arm64": "3.4.4",
"@lmdb/lmdb-darwin-x64": "3.4.4",
"@lmdb/lmdb-linux-arm": "3.4.4",
"@lmdb/lmdb-linux-arm64": "3.4.4",
"@lmdb/lmdb-linux-x64": "3.4.4",
"@lmdb/lmdb-win32-arm64": "3.4.4",
"@lmdb/lmdb-win32-x64": "3.4.4"
}
}

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display