modified hash function to deliver same value on 2 byte and 4 byte machines
authorceriel <none@none>
Thu, 31 Jan 1991 15:17:54 +0000 (15:17 +0000)
committerceriel <none@none>
Thu, 31 Jan 1991 15:17:54 +0000 (15:17 +0000)
util/led/sym.c

index 6647d7f..9805609 100644 (file)
@@ -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;
 }