Corrected lz4io
authorYann Collet <yann.collet.73@gmail.com>
Sun, 23 Nov 2014 00:14:04 +0000 (01:14 +0100)
committerYann Collet <yann.collet.73@gmail.com>
Sun, 23 Nov 2014 00:14:04 +0000 (01:14 +0100)
lz4.c
lz4.h
programs/lz4cli.c
programs/lz4io.c

diff --git a/lz4.c b/lz4.c
index 579a4fc..7e454fd 100644 (file)
--- a/lz4.c
+++ b/lz4.c
@@ -44,7 +44,7 @@
 
 /*
  * CPU_HAS_EFFICIENT_UNALIGNED_MEMORY_ACCESS :
- * You can force the code to use unaligned memory access if you know your CPU can handle it.
+ * You can force the code to use unaligned memory access if you know your CPU can handle it efficiently.
  */
 /* #define CPU_HAS_EFFICIENT_UNALIGNED_MEMORY_ACCESS 1 */
 
@@ -58,7 +58,9 @@
 #if defined(CPU_HAS_EFFICIENT_UNALIGNED_MEMORY_ACCESS) \
     || defined(__ARM_FEATURE_UNALIGNED) \
     || defined(__i386__) || defined(__x86_64__) \
-    || defined(_M_IX86) || defined(_M_X64)
+    || defined(_M_IX86) || defined(_M_X64) \
+    || defined(__ARM_ARCH_7__) || defined(__ARM_ARCH_8__) \
+    || (defined(_M_ARM) && (_M_ARM >= 7))
 #  define LZ4_UNALIGNED_ACCESS 1
 #else
 #  define LZ4_UNALIGNED_ACCESS 0
@@ -153,6 +155,7 @@ static U16 LZ4_readLE16(const void* memPtr)
 {
     if ((LZ4_UNALIGNED_ACCESS) && (LZ4_isLittleEndian()))
         return *(U16*)memPtr;
+    else
     {
         const BYTE* p = memPtr;
         return (U16)((U16)p[0] + (p[1]<<8));
@@ -166,6 +169,7 @@ static void LZ4_writeLE16(void* memPtr, U16 value)
         *(U16*)memPtr = value;
         return;
     }
+    else
     {
         BYTE* p = memPtr;
         p[0] = (BYTE) value;
@@ -202,6 +206,7 @@ static void LZ4_copy4(void* dstPtr, const void* srcPtr)
         *(U32*)dstPtr = *(U32*)srcPtr;
         return;
     }
+    else
     {
         BYTE* d = dstPtr;
         const BYTE* s = srcPtr;
@@ -216,6 +221,7 @@ static U64 LZ4_readLE64(const void* memPtr)
 {
     if ((LZ4_UNALIGNED_ACCESS) && (LZ4_isLittleEndian()))
         return *(U64*)memPtr;
+    else
     {
         const BYTE* p = memPtr;
         return (U64)((U64)p[0] + (p[1]<<8) + (p[2]<<16) + ((U64)p[3]<<24) +
@@ -249,6 +255,7 @@ static void LZ4_copy8(void* dstPtr, const void* srcPtr)
             ((U32*)dstPtr)[1] = ((U32*)srcPtr)[1];
         return;
     }
+    else
     {
         BYTE* d = dstPtr;
         const BYTE* s = srcPtr;
diff --git a/lz4.h b/lz4.h
index f995b05..c9ed49f 100644 (file)
--- a/lz4.h
+++ b/lz4.h
@@ -48,7 +48,7 @@ extern "C" {
 **************************************/
 #define LZ4_VERSION_MAJOR    1    /* for major interface/format changes  */
 #define LZ4_VERSION_MINOR    4    /* for minor interface/format changes  */
-#define LZ4_VERSION_RELEASE  0    /* for tweaks, bug-fixes, or development */
+#define LZ4_VERSION_RELEASE  1    /* 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);
 
index 2d612e7..9a6e5bc 100644 (file)
 //****************************
 #define COMPRESSOR_NAME "LZ4 Compression CLI"
 #ifndef LZ4_VERSION
-#  define LZ4_VERSION "r122"
+#  define LZ4_VERSION "r125"
 #endif
 #define AUTHOR "Yann Collet"
 #define WELCOME_MESSAGE "*** %s %i-bits %s, by %s (%s) ***\n", COMPRESSOR_NAME, (int)(sizeof(void*)*8), LZ4_VERSION, AUTHOR, __DATE__
index 3a84866..afaa59f 100644 (file)
@@ -357,7 +357,7 @@ int LZ4IO_compressFilename_Legacy(char* input_filename, char* output_filename, i
 static void* LZ4IO_LZ4_createStream (const char* inputBuffer)
 {
     (void)inputBuffer;
-    return calloc(4, LZ4_STREAMSIZE_U32);
+    return calloc(8, LZ4_STREAMSIZE_U64);
 }
 
 static int LZ4IO_LZ4_compress_limitedOutput_continue (void* ctx, const char* source, char* dest, int inputSize, int maxOutputSize, int compressionLevel)