Commit | Line | Data |
---|---|---|
54d22525 | 1 | /* hash.c -- gas hash table code |
b3adc24a | 2 | Copyright (C) 1987-2020 Free Software Foundation, Inc. |
252b5132 RH |
3 | |
4 | This file is part of GAS, the GNU Assembler. | |
5 | ||
6 | GAS is free software; you can redistribute it and/or modify | |
7 | it under the terms of the GNU General Public License as published by | |
ec2655a6 | 8 | the Free Software Foundation; either version 3, or (at your option) |
252b5132 RH |
9 | any later version. |
10 | ||
11 | GAS is distributed in the hope that it will be useful, | |
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 | GNU General Public License for more details. | |
15 | ||
16 | You should have received a copy of the GNU General Public License | |
54d22525 | 17 | along with GAS; see the file COPYING. If not, write to the Free |
4b4da160 NC |
18 | Software Foundation, 51 Franklin Street - Fifth Floor, Boston, MA |
19 | 02110-1301, USA. */ | |
54d22525 | 20 | |
252b5132 | 21 | #include "as.h" |
abebb03c ML |
22 | |
23 | /* Insert ELEMENT into HTAB. If the element exists, it is overwritten. */ | |
24 | ||
25 | void | |
26 | htab_insert (htab_t htab, PTR element) | |
27 | { | |
28 | void **slot = htab_find_slot (htab, element, INSERT); | |
29 | if (slot != NULL && htab->del_f) | |
30 | (*htab->del_f) (*slot); | |
31 | ||
32 | *slot = element; | |
33 | } | |
34 | ||
35 | /* Print statistics about a hash table. */ | |
36 | ||
37 | void | |
38 | htab_print_statistics (FILE *f, const char *name, htab_t table) | |
39 | { | |
40 | fprintf (f, "%s hash statistics:\n", name); | |
41 | fprintf (f, "\t%u searches\n", table->searches); | |
42 | fprintf (f, "\t%u collisions\n", table->collisions); | |
43 | fprintf (f, "\t%lu elements\n", (unsigned long) htab_elements (table)); | |
44 | fprintf (f, "\t%lu table size\n", (unsigned long) htab_size (table)); | |
45 | } |