diff options
author | Yann Collet <cyan@fb.com> | 2018-04-27 16:04:09 (GMT) |
---|---|---|
committer | Yann Collet <cyan@fb.com> | 2018-04-27 16:04:09 (GMT) |
commit | d294dd7fc684b1f46130358ff5c218e835082b16 (patch) | |
tree | 42941cf5bbd825ef6617da3925b13bbf13c89a51 /lib | |
parent | 0fb3a3b199ed0a92a402c5979c514a329b85462a (diff) | |
download | lz4-d294dd7fc684b1f46130358ff5c218e835082b16.zip lz4-d294dd7fc684b1f46130358ff5c218e835082b16.tar.gz lz4-d294dd7fc684b1f46130358ff5c218e835082b16.tar.bz2 |
ensure favorDecSpeed is properly initialized
also :
- fix a potential malloc error
- proper use of ALLOC macro inside lz4hc
- update html API doc
Diffstat (limited to 'lib')
-rw-r--r-- | lib/lz4.c | 6 | ||||
-rw-r--r-- | lib/lz4hc.c | 10 |
2 files changed, 8 insertions, 8 deletions
@@ -161,11 +161,11 @@ * Memory routines **************************************/ #include <stdlib.h> /* malloc, calloc, free */ -#define ALLOC(s) malloc(s) +#define ALLOC(s) malloc(s) #define ALLOC_AND_ZERO(s) calloc(1,s) -#define FREEMEM free +#define FREEMEM(p) free(p) #include <string.h> /* memset, memcpy */ -#define MEM_INIT memset +#define MEM_INIT(p,v,s) memset((p),(v),(s)) /*-************************************ diff --git a/lib/lz4hc.c b/lib/lz4hc.c index 35eac1a..1c7096b 100644 --- a/lib/lz4hc.c +++ b/lib/lz4hc.c @@ -805,7 +805,7 @@ int LZ4_compress_HC_extStateHC (void* state, const char* src, char* dst, int src int LZ4_compress_HC(const char* src, char* dst, int srcSize, int dstCapacity, int compressionLevel) { #if defined(LZ4HC_HEAPMODE) && LZ4HC_HEAPMODE==1 - LZ4_streamHC_t* const statePtr = (LZ4_streamHC_t*)malloc(sizeof(LZ4_streamHC_t)); + LZ4_streamHC_t* const statePtr = (LZ4_streamHC_t*)ALLOC(sizeof(LZ4_streamHC_t)); #else LZ4_streamHC_t state; LZ4_streamHC_t* const statePtr = &state; @@ -834,10 +834,9 @@ int LZ4_compress_HC_destSize(void* LZ4HC_Data, const char* source, char* dest, i **************************************/ /* allocation */ LZ4_streamHC_t* LZ4_createStreamHC(void) { - LZ4_streamHC_t* LZ4_streamHCPtr = (LZ4_streamHC_t*)malloc(sizeof(LZ4_streamHC_t)); - LZ4_streamHCPtr->internal_donotuse.end = (const BYTE *)(ptrdiff_t)-1; - LZ4_streamHCPtr->internal_donotuse.base = NULL; - LZ4_streamHCPtr->internal_donotuse.dictCtx = NULL; + LZ4_streamHC_t* const LZ4_streamHCPtr = (LZ4_streamHC_t*)ALLOC(sizeof(LZ4_streamHC_t)); + if (LZ4_streamHCPtr==NULL) return NULL; + LZ4_resetStreamHC(LZ4_streamHCPtr, LZ4HC_CLEVEL_DEFAULT); return LZ4_streamHCPtr; } @@ -857,6 +856,7 @@ void LZ4_resetStreamHC (LZ4_streamHC_t* LZ4_streamHCPtr, int compressionLevel) LZ4_streamHCPtr->internal_donotuse.end = (const BYTE *)(ptrdiff_t)-1; LZ4_streamHCPtr->internal_donotuse.base = NULL; LZ4_streamHCPtr->internal_donotuse.dictCtx = NULL; + LZ4_streamHCPtr->internal_donotuse.favorDecSpeed = 0; LZ4_setCompressionLevel(LZ4_streamHCPtr, compressionLevel); } |