- const U_CHAR *name;
- size_t len;
- unsigned int hash;
-{
- unsigned int index;
- unsigned int hash2;
- size_t size;
- cpp_hashnode *entry;
- cpp_hashnode **entries;
-
- entries = pfile->hashtab->entries;
- size = pfile->hashtab->size;
-
- hash += len;
- index = hash % size;
-
- entry = entries[index];
- if (entry == NULL)
- goto insert;
- if (entry->hash == hash && entry->length == len
- && !memcmp (entry->name, name, len))
- return entry;
-
- hash2 = 1 + hash % (size - 2);
-
- for (;;)
- {
- index += hash2;
- if (index >= size)
- index -= size;
- entry = entries[index];
-
- if (entry == NULL)
- goto insert;
- if (entry->hash == hash && entry->length == len
- && !memcmp (entry->name, name, len))
- return entry;
- }
-
- insert:
- pfile->hashtab->nelts++;
-
- /* Create a new hash node. */
- {
- U_CHAR *p = obstack_alloc (pfile->hash_ob, sizeof (cpp_hashnode) + len);
- entry = (cpp_hashnode *)p;
- p += offsetof (cpp_hashnode, name);
-
- entry->type = T_VOID;
- entry->fe_value = 0;
- entry->length = len;
- entry->hash = hash;
- entry->value.expansion = NULL;
- memcpy (p, name, len);
- p[len] = 0;
-
- entries[index] = entry;
- }
-
- if (size * 3 <= pfile->hashtab->nelts * 4)
- expand_hash (pfile->hashtab);
-
- return entry;
-}
-
-static void
-expand_hash (htab)
- struct htab *htab;