summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYann Collet <cyan@fb.com>2019-04-16 18:26:03 (GMT)
committerYann Collet <cyan@fb.com>2019-04-16 18:26:03 (GMT)
commit6fc763cd98eb9a487afc9c2577627c4028e43cef (patch)
tree19590ba5b87e06aae2ad4735a80e752940ca2030
parent108adfcb422ba5c2594a72b8fd5c9df38cc9ca6e (diff)
downloadlz4-6fc763cd98eb9a487afc9c2577627c4028e43cef.zip
lz4-6fc763cd98eb9a487afc9c2577627c4028e43cef.tar.gz
lz4-6fc763cd98eb9a487afc9c2577627c4028e43cef.tar.bz2
ensure consistent definition and usage of FREEMEM
as suggested by @sloutsky in #671
-rw-r--r--lib/lz4frame.c8
-rw-r--r--lib/lz4hc.c4
2 files changed, 6 insertions, 6 deletions
diff --git a/lib/lz4frame.c b/lib/lz4frame.c
index 19efd0b..42124e9 100644
--- a/lib/lz4frame.c
+++ b/lib/lz4frame.c
@@ -72,15 +72,15 @@
* by modifying below section.
*/
#include <stdlib.h> /* malloc, calloc, free */
-#define ALLOC(s) malloc(s)
#ifndef LZ4_SRC_INCLUDED /* avoid redefinition when sources are coalesced */
-# define ALLOC_AND_ZERO(s) calloc(1,(s))
+# define ALLOC(s) malloc(s)
+# define ALLOC_AND_ZERO(s) calloc(1,(s))
+# define FREEMEM(p) free(p)
#endif
-#define FREEMEM(p) free(p)
#include <string.h> /* memset, memcpy, memmove */
#ifndef LZ4_SRC_INCLUDED /* avoid redefinition when sources are coalesced */
-# define MEM_INIT memset
+# define MEM_INIT(p,v,s) memset((p),(v),(s))
#endif
diff --git a/lib/lz4hc.c b/lib/lz4hc.c
index f6ed779..d5f6743 100644
--- a/lib/lz4hc.c
+++ b/lib/lz4hc.c
@@ -868,7 +868,7 @@ int LZ4_compress_HC(const char* src, char* dst, int srcSize, int dstCapacity, in
#endif
int const cSize = LZ4_compress_HC_extStateHC(statePtr, src, dst, srcSize, dstCapacity, compressionLevel);
#if defined(LZ4HC_HEAPMODE) && LZ4HC_HEAPMODE==1
- free(statePtr);
+ FREEMEM(statePtr);
#endif
return cSize;
}
@@ -901,7 +901,7 @@ int LZ4_freeStreamHC (LZ4_streamHC_t* LZ4_streamHCPtr)
{
DEBUGLOG(4, "LZ4_freeStreamHC(%p)", LZ4_streamHCPtr);
if (!LZ4_streamHCPtr) return 0; /* support free on NULL */
- free(LZ4_streamHCPtr);
+ FREEMEM(LZ4_streamHCPtr);
return 0;
}