From 28e237e954098c418f048a871aa53199d92314f4 Mon Sep 17 00:00:00 2001 From: Yann Collet Date: Wed, 1 Apr 2015 15:53:08 +0100 Subject: simplified LZ4_compress_limitedOutput() --- lib/lz4.c | 19 +++---------------- lib/lz4.h | 2 +- 2 files changed, 4 insertions(+), 17 deletions(-) diff --git a/lib/lz4.c b/lib/lz4.c index 31dfc9f..b0ce64f 100644 --- a/lib/lz4.c +++ b/lib/lz4.c @@ -771,26 +771,13 @@ int LZ4_compress_withState (void* state, const char* source, char* dest, int inp int LZ4_compress_limitedOutput(const char* source, char* dest, int inputSize, int maxOutputSize) { #if (HEAPMODE) - void* ctx = ALLOCATOR(LZ4_STREAMSIZE_U64, 8); /* Aligned on 8-bytes boundaries */ + void* ctx = ALLOCATOR(LZ4_STREAMSIZE_U64, 8); /* malloc-calloc aligned on 8-bytes boundaries */ #else U64 ctx[LZ4_STREAMSIZE_U64] = {0}; /* Ensure data is aligned on 8-bytes boundaries */ #endif - int result; - if (maxOutputSize >= LZ4_compressBound(inputSize)) - { - if (inputSize < LZ4_64Klimit) - result = LZ4_compress_generic((void*)ctx, source, dest, inputSize, 0, notLimited, byU16, noDict, noDictIssue, 1); - else - result = LZ4_compress_generic((void*)ctx, source, dest, inputSize, 0, notLimited, LZ4_64bits() ? byU32 : byPtr, noDict, noDictIssue, 1); - } - else - { - if (inputSize < LZ4_64Klimit) - result = LZ4_compress_generic((void*)ctx, source, dest, inputSize, maxOutputSize, limitedOutput, byU16, noDict, noDictIssue, 1); - else - result = LZ4_compress_generic((void*)ctx, source, dest, inputSize, maxOutputSize, limitedOutput, LZ4_64bits() ? byU32 : byPtr, noDict, noDictIssue, 1); - } + int result = LZ4_compress_limitedOutput_withState(ctx, source, dest, inputSize, maxOutputSize); + #if (HEAPMODE) FREEMEM(ctx); #endif diff --git a/lib/lz4.h b/lib/lz4.h index 7072c37..92c8738 100644 --- a/lib/lz4.h +++ b/lib/lz4.h @@ -48,7 +48,7 @@ extern "C" { * Version **************************************/ #define LZ4_VERSION_MAJOR 1 /* for breaking interface changes */ -#define LZ4_VERSION_MINOR 6 /* for new (non-breaking) interface capabilities */ +#define LZ4_VERSION_MINOR 7 /* for new (non-breaking) interface capabilities */ #define LZ4_VERSION_RELEASE 0 /* for tweaks, bug-fixes, or development */ #define LZ4_VERSION_NUMBER (LZ4_VERSION_MAJOR *100*100 + LZ4_VERSION_MINOR *100 + LZ4_VERSION_RELEASE) int LZ4_versionNumber (void); -- cgit v0.12