summaryrefslogtreecommitdiff
path: root/src/lib/eina
diff options
context:
space:
mode:
authorvivek <vivek.ellur@samsung.com>2015-04-28 23:33:56 +0200
committerCedric BAIL <cedric@osg.samsung.com>2015-05-07 09:53:11 +0200
commit1fdc58a58061f044f5a701f8b96af2eb80027b52 (patch)
treef930f9047dfa3c8dbb84b553dc61be0de14e3117 /src/lib/eina
parenteec4a7bd0caa7d52bff6cc524ca12efa16d1445b (diff)
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.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>
Diffstat (limited to 'src/lib/eina')
-rw-r--r--src/lib/eina/eina_hash.h11
-rw-r--r--src/lib/eina/eina_inline_hash.x12
2 files changed, 23 insertions, 0 deletions
diff --git a/src/lib/eina/eina_hash.h b/src/lib/eina/eina_hash.h
index 460af00442..5f953bf865 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,
1157static inline int eina_hash_murmur3(const char *key, 1157static inline int eina_hash_murmur3(const char *key,
1158 int len) EINA_ARG_NONNULL(1); 1158 int len) EINA_ARG_NONNULL(1);
1159 1159
1160/**
1161 * @brief
1162 * Hash function using crc-32 algorithm and and 0xEDB88320 polynomial
1163 *
1164 * @param key The key to hash
1165 * @param len The length of the key
1166 * @return The hash value
1167 */
1168static inline int eina_hash_crc(const char *key,
1169 int len) EINA_ARG_NONNULL(1);
1170
1160#include "eina_inline_hash.x" 1171#include "eina_inline_hash.x"
1161 1172
1162/** 1173/**
diff --git a/src/lib/eina/eina_inline_hash.x b/src/lib/eina/eina_inline_hash.x
index 630e3479ba..71b0208c9c 100644
--- a/src/lib/eina/eina_inline_hash.x
+++ b/src/lib/eina/eina_inline_hash.x
@@ -19,6 +19,8 @@
19#ifndef EINA_INLINE_HASH_X_ 19#ifndef EINA_INLINE_HASH_X_
20#define EINA_INLINE_HASH_X_ 20#define EINA_INLINE_HASH_X_
21 21
22#include "eina_crc.h"
23
22EAPI extern unsigned int eina_seed; 24EAPI extern unsigned int eina_seed;
23 25
24/* 26/*
@@ -150,4 +152,14 @@ eina_hash_murmur3(const char *key, int len)
150 152
151 return _fmix32(h1); 153 return _fmix32(h1);
152} 154}
155
156static inline int
157eina_hash_crc(const char *key, int len)
158{
159 unsigned int crc;
160 unsigned int seed = 0xFFFFFFFF;
161
162 crc = eina_crc(key, len, seed, EINA_TRUE);
163 return (int)crc;
164}
153#endif 165#endif