- unsigned int hash = 0;
-
- while (*key)
- {
- hash += *(key++);
- hash += (hash << 10);
- hash ^= (hash >> 6);
- }
- hash += (hash << 3);
- hash ^= (hash >> 11);
- hash += (hash << 15);
- return hash;
-}
-
-struct termlist *termlist_create(NMEM nmem, int numterms, int highscore_size)
-{
- int hashsize = 1;
- int halfnumterms;
- struct termlist *res;
-
- // Calculate a hash size smallest power of 2 larger than 50% of expected numterms
- halfnumterms = numterms >> 1;
- if (halfnumterms < 0)
- halfnumterms = 1;
- while (hashsize < halfnumterms)
- hashsize <<= 1;
- res = nmem_malloc(nmem, sizeof(struct termlist));
- res->hashtable = nmem_malloc(nmem, hashsize * sizeof(struct termlist_bucket*));
- memset(res->hashtable, 0, hashsize * sizeof(struct termlist_bucket*));
- res->hashtable_size = hashsize;
+ struct termlist *res = nmem_malloc(nmem, sizeof(struct termlist));
+ res->hash_size = 399;
+ res->hashtable =
+ nmem_malloc(nmem, res->hash_size * sizeof(struct termlist_bucket*));
+ memset(res->hashtable, 0, res->hash_size * sizeof(struct termlist_bucket*));