eina: add crc hash function to eina hash module.
authorvivek <vivek.ellur@samsung.com>
Tue, 28 Apr 2015 21:33:56 +0000 (23:33 +0200)
committerCedric BAIL <cedric@osg.samsung.com>
Thu, 7 May 2015 07:53:11 +0000 (09:53 +0200)
Summary:
Added eina_hash_crc function in eina hash module to generate hash code
using crc-32.

Signed-off-by: vivek <vivek.ellur@samsung.com>
Reviewers: Sergeant_Whitespace, cedric

Subscribers: Sergeant_Whitespace, cedric

Differential Revision: https://phab.enlightenment.org/D2273

Signed-off-by: Cedric BAIL <cedric@osg.samsung.com>
src/lib/eina/eina_hash.h
src/lib/eina/eina_inline_hash.x

index 460af00..5f953bf 100644 (file)
@@ -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"
 
 /**
index 630e347..71b0208 100644 (file)
@@ -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