Lines Matching refs:table
1 /* hash.c -- gas hash table code
21 /* This version of the hash table code is a wholescale replacement of
22 the old hash table code, which was fairly bad. This is based on
23 the hash table code in BFD, but optimized slightly for the
25 are stored in the hash table. Instead, it always stores a pointer.
26 The assembler uses the hash table mostly to store symbols, and we
27 don't need to confuse the symbol structure with a hash table
34 /* An entry in a hash table. */
42 table. */
44 /* Pointer being stored in the hash table. */
48 /* A hash table. */
52 struct hash_entry **table;
53 /* The number of slots in the hash table. */
55 /* An obstack for this hash table. */
69 /* The default number of entries to use when creating a hash table.
82 /* Create a hash table. This return a control block. */
93 ret->table = (struct hash_entry **) obstack_alloc (&ret->memory, alloc);
94 memset (ret->table, 0, alloc);
115 /* Delete a hash table, freeing all allocated memory. */
118 hash_die (struct hash_control *table)
120 obstack_free (&table->memory, 0);
121 free (table);
124 /* Look up a string in a hash table. This returns a pointer to the
125 hash_entry, or NULL if the string is not in the table. If PLIST is
134 hash_lookup (struct hash_control *table, const char *key, size_t len,
146 ++table->lookups;
162 hindex = hash % table->size;
163 list = table->table + hindex;
172 ++table->hash_compares;
178 ++table->string_compares;
200 /* Insert an entry into a hash table. This returns NULL on success.
203 hash table. */
206 hash_insert (struct hash_control *table, const char *key, void *val)
212 p = hash_lookup (table, key, strlen (key), &list, &hash);
217 ++table->insertions;
220 p = (struct hash_entry *) obstack_alloc (&table->memory, sizeof (*p));
231 /* Insert or replace an entry in a hash table. This returns NULL on
236 hash_jam (struct hash_control *table, const char *key, void *val)
242 p = hash_lookup (table, key, strlen (key), &list, &hash);
246 ++table->replacements;
254 ++table->insertions;
257 p = (struct hash_entry *) obstack_alloc (&table->memory, sizeof (*p));
269 /* Replace an existing entry in a hash table. This returns the old
271 table, this does nothing and returns NULL. */
274 hash_replace (struct hash_control *table, const char *key, void *value)
279 p = hash_lookup (table, key, strlen (key), NULL, NULL);
284 ++table->replacements;
294 /* Find an entry in a hash table, returning its value. Returns NULL
298 hash_find (struct hash_control *table, const char *key)
302 p = hash_lookup (table, key, strlen (key), NULL, NULL);
313 hash_find_n (struct hash_control *table, const char *key, size_t len)
317 p = hash_lookup (table, key, len, NULL, NULL);
324 /* Delete an entry from a hash table. This returns the value stored
328 hash_delete (struct hash_control *table, const char *key, int freeme)
333 p = hash_lookup (table, key, strlen (key), &list, NULL);
341 ++table->deletions;
347 obstack_free (&table->memory, p);
352 /* Traverse a hash table. Call the function on every entry in the
353 hash table. */
356 hash_traverse (struct hash_control *table,
361 for (i = 0; i < table->size; ++i)
365 for (p = table->table[i]; p != NULL; p = p->next)
370 /* Print hash table statistics on the specified file. NAME is the
371 name of the hash table, used for printing a header. */
376 struct hash_control *table ATTRIBUTE_UNUSED)
384 fprintf (f, "\t%lu lookups\n", table->lookups);
385 fprintf (f, "\t%lu hash comparisons\n", table->hash_compares);
386 fprintf (f, "\t%lu string comparisons\n", table->string_compares);
387 fprintf (f, "\t%lu insertions\n", table->insertions);
388 fprintf (f, "\t%lu replacements\n", table->replacements);
389 fprintf (f, "\t%lu deletions\n", table->deletions);
393 for (i = 0; i < table->size; ++i)
397 if (table->table[i] == NULL)
401 for (p = table->table[i]; p != NULL; p = p->next)
406 fprintf (f, "\t%g average chain length\n", (double) total / table->size);
414 /* This test program is left over from the old hash table code. */
441 /* Number 0:TABLES-1 of current hashed symbol table. */
464 printf ("old hash table #=%d.\n", number);
470 printf ("address of hash table #%d control block is %xx\n",
486 printf ("# show old, select new default hash table number\n");
488 printf ("a apply a simple display-er to each symbol in table\n");
496 printf ("s say what %% of table is used\n");
498 printf ("x delete a symbol from table, report its value\n");
569 /* Determine number: what hash table to use.
577 printf (" what hash table (%d:%d) ? ", 0, TABLES - 1);
585 printf ("warning: current hash-table-#%d. has no hash-control\n", number);
591 printf ("invalid hash table number: %d\n", number);