comparison src/hash.c @ 410:de805c49cfc1 r21-2-35

Import from CVS: tag r21-2-35
author cvs
date Mon, 13 Aug 2007 11:19:21 +0200
parents 74fd4e045ea6
children 697ef44129c6
comparison
equal deleted inserted replaced
409:301b9ebbdf3b 410:de805c49cfc1
40 unsigned const char *x = (unsigned const char *) xv; 40 unsigned const char *x = (unsigned const char *) xv;
41 41
42 if (!x) return 0; 42 if (!x) return 0;
43 43
44 while (size--) 44 while (size--)
45 {
46 unsigned int g;
47 h = (h << 4) + *x++;
48 if ((g = h & 0xf0000000) != 0)
49 h = (h ^ (g >> 24)) ^ g;
50 }
51
52 return h;
53 }
54
55 unsigned long
56 string_hash (const char *xv)
57 {
58 unsigned int h = 0;
59 unsigned const char *x = (unsigned const char *) xv;
60
61 if (!x) return 0;
62
63 while (*x)
45 { 64 {
46 unsigned int g; 65 unsigned int g;
47 h = (h << 4) + *x++; 66 h = (h << 4) + *x++;
48 if ((g = h & 0xf0000000) != 0) 67 if ((g = h & 0xf0000000) != 0)
49 h = (h ^ (g >> 24)) ^ g; 68 h = (h ^ (g >> 24)) ^ g;