aboutsummaryrefslogtreecommitdiff
path: root/gas/hash.c
diff options
context:
space:
mode:
Diffstat (limited to 'gas/hash.c')
-rw-r--r--gas/hash.c22
1 files changed, 16 insertions, 6 deletions
diff --git a/gas/hash.c b/gas/hash.c
index 42fe5a2..0734430 100644
--- a/gas/hash.c
+++ b/gas/hash.c
@@ -20,16 +20,26 @@
#include "as.h"
-/* Insert ELEMENT into HTAB. If the element exists, it is overwritten. */
+/* Insert ELEMENT into HTAB. If REPLACE is non-zero existing elements
+ are overwritten. If ELEMENT already exists, a pointer to the slot
+ is returned. Otherwise NULL is returned. */
-void
-htab_insert (htab_t htab, PTR element)
+void **
+htab_insert (htab_t htab, void *element, int replace)
{
void **slot = htab_find_slot (htab, element, INSERT);
- if (slot != NULL && htab->del_f)
- (*htab->del_f) (*slot);
-
+ if (*slot != NULL)
+ {
+ if (replace)
+ {
+ if (htab->del_f)
+ (*htab->del_f) (*slot);
+ *slot = element;
+ }
+ return slot;
+ }
*slot = element;
+ return NULL;
}
/* Print statistics about a hash table. */