Fixed cast-align warnings on 32-bits
authorYann Collet <yann.collet.73@gmail.com>
Wed, 25 Mar 2015 17:06:40 +0000 (18:06 +0100)
committerYann Collet <yann.collet.73@gmail.com>
Wed, 25 Mar 2015 17:06:40 +0000 (18:06 +0100)
lib/lz4.c
lib/lz4.h
lib/lz4hc.c
lib/lz4hc.h
lib/xxhash.h

index e15a022..881d1af 100644 (file)
--- a/lib/lz4.c
+++ b/lib/lz4.c
@@ -1321,7 +1321,7 @@ void* LZ4_create (const char* inputBuffer)
 char* LZ4_slideInputBuffer (void* LZ4_Data)
 {
     LZ4_stream_t_internal* ctx = (LZ4_stream_t_internal*)LZ4_Data;
-    int dictSize = LZ4_saveDict((LZ4_stream_t*)ctx, (char*)ctx->bufferStart, 64 KB);
+    int dictSize = LZ4_saveDict((LZ4_stream_t*)LZ4_Data, (char*)ctx->bufferStart, 64 KB);
     return (char*)(ctx->bufferStart + dictSize);
 }
 
index 7b938da..de43fc0 100644 (file)
--- a/lib/lz4.h
+++ b/lib/lz4.h
@@ -39,8 +39,8 @@ extern "C" {
 #endif
 
 /*
- * lz4.h provides raw compression format functions, for optimal performance and integration into programs.
- * If you need to generate data using an inter-operable format (respecting the framing specification),
+ * lz4.h provides block compression functions, for optimal performance.
+ * If you need to generate inter-operable compressed data (respecting LZ4 frame specification),
  * please use lz4frame.h instead.
 */
 
index 357fa96..a03c511 100644 (file)
@@ -594,7 +594,7 @@ int LZ4_freeStreamHC (LZ4_streamHC_t* LZ4_streamHCPtr) { free(LZ4_streamHCPtr);
 /* initialization */
 void LZ4_resetStreamHC (LZ4_streamHC_t* LZ4_streamHCPtr, int compressionLevel)
 {
-    LZ4_STATIC_ASSERT(sizeof(LZ4HC_Data_Structure) <= LZ4_STREAMHCSIZE);   /* if compilation fails here, LZ4_STREAMHCSIZE must be increased */
+    LZ4_STATIC_ASSERT(sizeof(LZ4HC_Data_Structure) <= sizeof(LZ4_streamHC_t));   /* if compilation fails here, LZ4_STREAMHCSIZE must be increased */
     ((LZ4HC_Data_Structure*)LZ4_streamHCPtr)->base = NULL;
     ((LZ4HC_Data_Structure*)LZ4_streamHCPtr)->compressionLevel = (unsigned)compressionLevel;
 }
index eb72051..4a05845 100644 (file)
@@ -79,7 +79,7 @@ int LZ4_compressHC2_limitedOutput (const char* source, char* dest, int inputSize
 
 
 /**************************************
-   Using an external allocation
+*  Using an external allocation
 **************************************/
 int LZ4_sizeofStateHC(void);
 int LZ4_compressHC_withStateHC               (void* state, const char* source, char* dest, int inputSize);
@@ -102,12 +102,18 @@ They just use the externally allocated memory for state instead of allocating th
 
 
 
+/*****************************
+*  Includes
+*****************************/
+#include <stddef.h>   /* size_t */
+
+
 /**************************************
-   Experimental Streaming Functions
+*  Experimental Streaming Functions
 **************************************/
-#define LZ4_STREAMHCSIZE_U64 32774
-#define LZ4_STREAMHCSIZE     (LZ4_STREAMHCSIZE_U64 * sizeof(unsigned long long))
-typedef struct { unsigned long long table[LZ4_STREAMHCSIZE_U64]; } LZ4_streamHC_t;
+#define LZ4_STREAMHCSIZE        262192
+#define LZ4_STREAMHCSIZE_SIZET (LZ4_STREAMHCSIZE / sizeof(size_t))
+typedef struct { size_t table[LZ4_STREAMHCSIZE_SIZET]; } LZ4_streamHC_t;
 /*
 LZ4_streamHC_t
 This structure allows static allocation of LZ4 HC streaming state.
index 99b0c27..34eea73 100644 (file)
@@ -56,6 +56,12 @@ SHA1-32         0.28 GB/s    10
 Q.Score is a measure of quality of the hash function.
 It depends on successfully passing SMHasher test set.
 10 is a perfect score.
+
+A new 64-bits version, named XXH64, is available since r35.
+It offers better speed for 64-bits applications.
+Name     Speed on 64 bits    Speed on 32 bits
+XXH64       13.8 GB/s            1.9 GB/s
+XXH32        6.8 GB/s            6.0 GB/s
 */
 
 #pragma once
@@ -66,20 +72,15 @@ extern "C" {
 
 
 /*****************************
-   Includes
+*  Definitions
 *****************************/
 #include <stddef.h>   /* size_t */
-
-
-/*****************************
-   Type
-*****************************/
 typedef enum { XXH_OK=0, XXH_ERROR } XXH_errorcode;
 
 
 
 /*****************************
-   Simple Hash Functions
+*  Simple Hash Functions
 *****************************/
 
 unsigned int       XXH32 (const void* input, size_t length, unsigned seed);
@@ -94,12 +95,13 @@ XXH32() :
     Speed on Core 2 Duo @ 3 GHz (single thread, SMHasher benchmark) : 5.4 GB/s
 XXH64() :
     Calculate the 64-bits hash of sequence of length "len" stored at memory address "input".
+    Faster on 64-bits systems. Slower on 32-bits systems.
 */
 
 
 
 /*****************************
-   Advanced Hash Functions
+*  Advanced Hash Functions
 *****************************/
 typedef struct { long long ll[ 6]; } XXH32_state_t;
 typedef struct { long long ll[11]; } XXH64_state_t;