modified hash function to deliver same value on 2 byte and 4 byte machines
This commit is contained in:
parent
ae5dded36f
commit
2c3dcb0547
1 changed files with 3 additions and 3 deletions
|
@ -26,7 +26,7 @@ struct symbol {
|
|||
ind_t sy_next;
|
||||
};
|
||||
|
||||
#define NHASH 256 /* Size of hash table. Should be even. */
|
||||
#define NHASH 307 /* Size of hash table. Must be odd. */
|
||||
|
||||
static ind_t hashtable[NHASH];
|
||||
|
||||
|
@ -134,12 +134,12 @@ int
|
|||
hash(p)
|
||||
register char *p;
|
||||
{
|
||||
register unsigned int h = 0;
|
||||
register unsigned short h = 0;
|
||||
register int c;
|
||||
|
||||
while (c = *p++) {
|
||||
h <<= 2;
|
||||
h += c;
|
||||
}
|
||||
return h & (NHASH - 1);
|
||||
return h % NHASH;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue