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>
This commit is contained in:
parent
eec4a7bd0c
commit
1fdc58a580
|
@ -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"
|
||||
|
||||
/**
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue