aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/libraries/eet/src/lib/eet_utils.c
diff options
context:
space:
mode:
Diffstat (limited to 'libraries/eet/src/lib/eet_utils.c')
-rw-r--r--libraries/eet/src/lib/eet_utils.c36
1 files changed, 36 insertions, 0 deletions
diff --git a/libraries/eet/src/lib/eet_utils.c b/libraries/eet/src/lib/eet_utils.c
new file mode 100644
index 0000000..8e591a2
--- /dev/null
+++ b/libraries/eet/src/lib/eet_utils.c
@@ -0,0 +1,36 @@
1#ifdef HAVE_CONFIG_H
2# include <config.h>
3#endif /* ifdef HAVE_CONFIG_H */
4
5#include <stdio.h>
6#include <math.h>
7
8#include "Eet.h"
9#include "Eet_private.h"
10
11int
12_eet_hash_gen(const char *key,
13 int hash_size)
14{
15 int hash_num = 0;
16 int value, i;
17 int mask;
18 unsigned char *ptr;
19
20 /* no string - index 0 */
21 if (!key)
22 return 0;
23
24 /* calc hash num */
25 for (i = 0, ptr = (unsigned char *)key, value = (int)(*ptr);
26 value;
27 ptr++, i++, value = (int)(*ptr))
28 hash_num ^= (value | (value << 8)) >> (i & 0x7);
29
30 /* mask it */
31 mask = (1 << hash_size) - 1;
32 hash_num &= mask;
33 /* return it */
34 return hash_num;
35} /* _eet_hash_gen */
36