From 86023f01f207f3561766bf33a0c3d935786ae5f9 Mon Sep 17 00:00:00 2001
From: Yann Collet makes it possible to set or read frame parameters.
- It's not required to set all fields, as long as the structure was initially memset() to zero.
- For all fields, 0 sets it to default value
+ Structure must be first init to 0, using memset() or LZ4F_INIT_FRAMEINFO,
+ setting all parameters to default.
+ It's then possible to update selectively some parameters
makes it possible to supply detailed compression parameters to the stream interface.
- Structure is presumed initially memset() to zero, representing default settings.
+ makes it possible to supply advanced compression instructions to streaming interface.
+ Structure must be first init to 0, using memset() or LZ4F_INIT_PREFERENCES,
+ setting all parameters to default.
All reserved fields must be set to zero.
Introduction
- LZ4 is lossless compression algorithm, providing compression speed at 400 MB/s per core,
+ LZ4 is lossless compression algorithm, providing compression speed at 500 MB/s per core,
scalable with multi-cores CPU. It features an extremely fast decoder, with speed in
multiple GB/s per core, typically reaching RAM speed limits on multi-core systems.
@@ -37,8 +37,8 @@
An additional format, called LZ4 frame specification (doc/lz4_Frame_format.md),
take care of encoding standard metadata alongside LZ4-compressed blocks.
- If your application requires interoperability, it's recommended to use it.
- A library is provided to take care of it, see lz4frame.h.
+ Frame format is required for interoperability.
+ It is delivered through a companion API, declared in lz4frame.h.
Version
diff --git a/doc/lz4frame_manual.html b/doc/lz4frame_manual.html
index fb8e0ce..72e6782 100644
--- a/doc/lz4frame_manual.html
+++ b/doc/lz4frame_manual.html
@@ -84,19 +84,21 @@
LZ4F_blockChecksum_t blockChecksumFlag; /* 1: each block followed by a checksum of block's compressed data; 0: disabled (default) */
} LZ4F_frameInfo_t;
typedef struct {
LZ4F_frameInfo_t frameInfo;
int compressionLevel; /* 0: default (fast mode); values > LZ4HC_CLEVEL_MAX count as LZ4HC_CLEVEL_MAX; values < 0 trigger "fast acceleration" */
- unsigned autoFlush; /* 1: always flush, to reduce usage of internal buffers */
- unsigned favorDecSpeed; /* 1: parser favors decompression speed vs compression ratio. Only works for high compression modes (>= LZ4LZ4HC_CLEVEL_OPT_MIN) */ /* >= v1.8.2 */
+ unsigned autoFlush; /* 1: always flush; reduces usage of internal buffers */
+ unsigned favorDecSpeed; /* 1: parser favors decompression speed vs compression ratio. Only works for high compression modes (>= LZ4HC_CLEVEL_OPT_MIN) */ /* v1.8.2+ */
unsigned reserved[3]; /* must be zero for forward compatibility */
} LZ4F_preferences_t;
-
@@ -295,7 +297,8 @@ LZ4F_errorCode_t LZ4F_freeDecompressionContext(LZ4F_dctx* dctx);
and start a new one using same context resources.
typedef enum { LZ4F_LIST_ERRORS(LZ4F_GENERATE_ENUM) } LZ4F_errorCodes; +typedef enum { LZ4F_LIST_ERRORS(LZ4F_GENERATE_ENUM) + _LZ4F_dummy_error_enum_for_c89_never_used } LZ4F_errorCodes;
Bulk processing dictionary API
diff --git a/examples/frameCompress.c b/examples/frameCompress.c index a0c5d3d..2cc4649 100644 --- a/examples/frameCompress.c +++ b/examples/frameCompress.c @@ -184,8 +184,8 @@ decompress_file_internal(FILE* f_in, FILE* f_out, while (ret != 0) { /* Load more input */ size_t readSize = firstChunk ? filled : fread(src, 1, srcCapacity, f_in); firstChunk=0; - const void* srcPtr = src + alreadyConsumed; alreadyConsumed=0; - const void* const srcEnd = srcPtr + readSize; + const void* srcPtr = (const char*)src + alreadyConsumed; alreadyConsumed=0; + const void* const srcEnd = (const char*)srcPtr + readSize; if (readSize == 0 || ferror(f_in)) { printf("Decompress: not enough input or error reading file\n"); return 1; @@ -198,7 +198,7 @@ decompress_file_internal(FILE* f_in, FILE* f_out, while (srcPtr < srcEnd && ret != 0) { /* Any data within dst has been flushed at this stage */ size_t dstSize = dstCapacity; - size_t srcSize = srcEnd - srcPtr; + size_t srcSize = (const char*)srcEnd - (const char*)srcPtr; ret = LZ4F_decompress(dctx, dst, &dstSize, srcPtr, &srcSize, /* LZ4F_decompressOptions_t */ NULL); if (LZ4F_isError(ret)) { printf("Decompression error: %s\n", LZ4F_getErrorName(ret)); @@ -207,7 +207,7 @@ decompress_file_internal(FILE* f_in, FILE* f_out, /* Flush output */ if (dstSize != 0) safe_fwrite(dst, 1, dstSize, f_out); /* Update input */ - srcPtr += srcSize; + srcPtr = (const char*)srcPtr + srcSize; } assert(srcPtr <= srcEnd); diff --git a/lib/lz4frame.c b/lib/lz4frame.c index 08bf0fa..a30de48 100644 --- a/lib/lz4frame.c +++ b/lib/lz4frame.c @@ -33,8 +33,8 @@ You can contact the author at : */ /* LZ4F is a stand-alone API to create LZ4-compressed Frames -* in full conformance with specification v1.5.0 -* All related operations, including memory management, are handled by the library. +* in full conformance with specification v1.6.1 . +* This library rely upon memory management capabilities. * */ @@ -63,9 +63,9 @@ You can contact the author at : * Memory routines **************************************/ #include/* malloc, calloc, free */ -#define ALLOC(s) malloc(s) -#define ALLOC_AND_ZERO(s) calloc(1,s) -#define FREEMEM free +#define ALLOC(s) malloc(s) +#define ALLOC_AND_ZERO(s) calloc(1,(s)) +#define FREEMEM(p) free(p) #include /* memset, memcpy, memmove */ #define MEM_INIT memset diff --git a/lib/lz4frame.h b/lib/lz4frame.h index 75f1fd9..fc30f6f 100644 --- a/lib/lz4frame.h +++ b/lib/lz4frame.h @@ -427,15 +427,15 @@ LZ4FLIB_API void LZ4F_resetDecompressionContext(LZ4F_dctx* dctx); /* always su extern "C" { #endif -/* These declarations are not stable and may change in the future. They are - * therefore only safe to depend on when the caller is statically linked - * against the library. To access their declarations, define - * LZ4F_STATIC_LINKING_ONLY. +/* These declarations are not stable and may change in the future. + * They are therefore only safe to depend on + * when the caller is statically linked against the library. + * To access their declarations, define LZ4F_STATIC_LINKING_ONLY. * - * There is a further protection mechanism where these symbols aren't published - * into shared/dynamic libraries. You can override this behavior and force - * them to be published by defining LZ4F_PUBLISH_STATIC_FUNCTIONS. Use at - * your own risk. + * By default, these symbols aren't published into shared/dynamic libraries. + * You can override this behavior and force them to be published + * by defining LZ4F_PUBLISH_STATIC_FUNCTIONS. + * Use at your own risk. */ #ifdef LZ4F_PUBLISH_STATIC_FUNCTIONS #define LZ4FLIB_STATIC_API LZ4FLIB_API @@ -471,12 +471,12 @@ extern "C" { #define LZ4F_GENERATE_ENUM(ENUM) LZ4F_##ENUM, /* enum list is exposed, to handle specific errors */ -typedef enum { LZ4F_LIST_ERRORS(LZ4F_GENERATE_ENUM) } LZ4F_errorCodes; +typedef enum { LZ4F_LIST_ERRORS(LZ4F_GENERATE_ENUM) + _LZ4F_dummy_error_enum_for_c89_never_used } LZ4F_errorCodes; LZ4FLIB_STATIC_API LZ4F_errorCodes LZ4F_getErrorCode(size_t functionResult); - /********************************** * Bulk processing dictionary API *********************************/ diff --git a/lib/lz4hc.c b/lib/lz4hc.c index e913ee7..87f4cdb 100644 --- a/lib/lz4hc.c +++ b/lib/lz4hc.c @@ -400,7 +400,7 @@ int LZ4HC_InsertAndFindBestMatch(LZ4HC_CCtx_internal* const hc4, /* Index tabl typedef enum { noLimit = 0, limitedOutput = 1, - limitedDestSize = 2, + limitedDestSize = 2 } limitedOutput_directive; /* LZ4HC_encodeSequence() : -- cgit v0.12