add SVN update log into debian/changelog:
[framework/uifw/eet.git] / src / lib / eet_utils.c
1 /*
2  * vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2
3  */
4
5 #ifdef HAVE_CONFIG_H
6 # include <config.h>
7 #endif
8
9 #include <stdio.h>
10 #include <math.h>
11
12 #include "Eet.h"
13 #include "Eet_private.h"
14
15 int
16 _eet_hash_gen(const char *key, int hash_size)
17 {
18    int                  hash_num = 0;
19    int                  value, i;
20    int                  mask;
21    unsigned char        *ptr;
22
23    /* no string - index 0 */
24    if (!key) return 0;
25
26    /* calc hash num */
27    for (i = 0, ptr = (unsigned char *)key, value = (int)(*ptr);
28         value;
29         ptr++, i++, value = (int)(*ptr))
30      hash_num ^= (value | (value << 8)) >> (i & 0x7);
31
32    /* mask it */
33    mask = (1 << hash_size) - 1;
34    hash_num &= mask;
35    /* return it */
36    return hash_num;
37 }
38