Fix several warnings that appear in gcc 4.3.2.
[wvstreams.git] / utils / wvhash.cc
blobe93ef870e1833f201faf4291afb93bf133c2e3b8
1 #include "wvhash.h"
3 // Note: this hash function is case-insensitive since it ignores the
4 // bit in ASCII that defines case. You may want to take advantage of this.
5 unsigned int WvHash(const char *s)
7 unsigned hash = 0, slide, andval;
8 if (!s) return 0;
10 slide = sizeof(hash)*8 - 5;
11 andval = 0x1F << slide;
13 while (*s)
14 hash = (hash<<4) ^ (*(s++) & 0x1F) ^ ((hash & andval) >> slide);
16 return hash;
19 unsigned WvHash(WvStringParm s)
21 return !s ? 0 : WvHash((const char *)s);
24 // FIXME: does this suck?
25 unsigned WvHash(const int &i)
27 return i;
31 unsigned WvHash(const void *p)
33 return reinterpret_cast<unsigned long>(p);