cedric pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=1fdc58a58061f044f5a701f8b96af2eb80027b52

commit 1fdc58a58061f044f5a701f8b96af2eb80027b52
Author: vivek <vivek.el...@samsung.com>
Date:   Tue Apr 28 23:33:56 2015 +0200

    eina: add crc hash function to eina hash module.
    
    Summary:
    Added eina_hash_crc function in eina hash module to generate hash code
    using crc-32.
    
    Signed-off-by: vivek <vivek.el...@samsung.com>
    
    Reviewers: Sergeant_Whitespace, cedric
    
    Subscribers: Sergeant_Whitespace, cedric
    
    Differential Revision: https://phab.enlightenment.org/D2273
    
    Signed-off-by: Cedric BAIL <ced...@osg.samsung.com>
---
 src/lib/eina/eina_hash.h        | 11 +++++++++++
 src/lib/eina/eina_inline_hash.x | 12 ++++++++++++
 2 files changed, 23 insertions(+)

diff --git a/src/lib/eina/eina_hash.h b/src/lib/eina/eina_hash.h
index 460af00..5f953bf 100644
--- a/src/lib/eina/eina_hash.h
+++ b/src/lib/eina/eina_hash.h
@@ -1157,6 +1157,17 @@ static inline int eina_hash_int64(const unsigned long 
long int *pkey,
 static inline int eina_hash_murmur3(const char *key,
                            int         len) EINA_ARG_NONNULL(1);
 
+/**
+ * @brief
+ * Hash function using crc-32 algorithm and and 0xEDB88320 polynomial
+ *
+ * @param key The key to hash
+ * @param len The length of the key
+ * @return The hash value
+ */
+static inline int eina_hash_crc(const char *key,
+                           int         len) EINA_ARG_NONNULL(1);
+
 #include "eina_inline_hash.x"
 
 /**
diff --git a/src/lib/eina/eina_inline_hash.x b/src/lib/eina/eina_inline_hash.x
index 630e347..71b0208 100644
--- a/src/lib/eina/eina_inline_hash.x
+++ b/src/lib/eina/eina_inline_hash.x
@@ -19,6 +19,8 @@
 #ifndef EINA_INLINE_HASH_X_
 #define EINA_INLINE_HASH_X_
 
+#include "eina_crc.h"
+
 EAPI extern unsigned int eina_seed;
 
 /*
@@ -150,4 +152,14 @@ eina_hash_murmur3(const char *key, int len)
 
    return _fmix32(h1);
 }
+
+static inline int
+eina_hash_crc(const char *key, int len)
+{
+   unsigned int crc;
+   unsigned int seed = 0xFFFFFFFF;
+
+   crc = eina_crc(key, len, seed, EINA_TRUE);
+   return (int)crc;
+}
 #endif

-- 


Reply via email to