- * _nc_make_hash_table()
- *
- * Takes the entries in table[] and hashes them into hash_table[]
- * by name. There are CAPTABSIZE entries in table[] and HASHTABSIZE
- * slots in hash_table[].
- *
- */
-
-#ifdef MAIN_PROGRAM
-
-#undef MODULE_ID
-#define MODULE_ID(id) /*nothing */
-#include <tinfo/doalloc.c>
-
-static void
-_nc_make_hash_table(struct name_table_entry *table,
- struct name_table_entry **hash_table)
-{
- int i;
- int hashvalue;
- int collisions = 0;
-
- for (i = 0; i < CAPTABSIZE; i++) {
- hashvalue = hash_function(table[i].nte_name);
-
- if (hash_table[hashvalue] != (struct name_table_entry *) 0)
- collisions++;
-
- if (hash_table[hashvalue] != 0)
- table[i].nte_link = (short) (hash_table[hashvalue] - table);
- hash_table[hashvalue] = &table[i];
- }
-
- DEBUG(4, ("Hash table complete: %d collisions out of %d entries",
- collisions, CAPTABSIZE));
-}
-#endif
-
-/*
- * int hash_function(string)
- *
- * Computes the hashing function on the given string.
- *
- * The current hash function is the sum of each consectutive pair
- * of characters, taken as two-byte integers, mod HASHTABSIZE.
- *
- */
-
-static int
-hash_function(const char *string)
-{
- long sum = 0;
-
- DEBUG(9, ("hashing %s", string));
- while (*string) {
- sum += (long) (*string + (*(string + 1) << 8));
- string++;
- }
-
- DEBUG(9, ("sum is %ld", sum));
- return (int) (sum % HASHTABSIZE);
-}
-
-/*
- * struct name_table_entry *
- * find_entry(string)
- *
- * Finds the entry for the given string in the hash table if present.
- * Returns a pointer to the entry in the table or 0 if not found.
- *