[07/19] Convert breakpoint.c to new hash table

Message ID 20230407-t-robin-hood-hash-v1-7-900d93ef1510@tromey.com
State New
Headers
Series Add hash table to gdbsupport |

Commit Message

Tom Tromey April 7, 2023, 3:25 p.m. UTC
  This converts breakpoint.c to use the new hash table.
---
 gdb/breakpoint.c | 16 ++++++----------
 1 file changed, 6 insertions(+), 10 deletions(-)
  

Patch

diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c
index ebe97940f54..3e380a1fd0b 100644
--- a/gdb/breakpoint.c
+++ b/gdb/breakpoint.c
@@ -20,7 +20,6 @@ 
 #include "defs.h"
 #include "arch-utils.h"
 #include <ctype.h>
-#include "hashtab.h"
 #include "symtab.h"
 #include "frame.h"
 #include "breakpoint.h"
@@ -81,6 +80,7 @@ 
 #include "progspace-and-thread.h"
 #include "gdbsupport/array-view.h"
 #include "gdbsupport/gdb_optional.h"
+#include "gdbsupport/hash-table.h"
 
 /* Prototypes for local functions.  */
 
@@ -12489,25 +12489,21 @@  static bool
 ambiguous_names_p (struct bp_location *loc)
 {
   struct bp_location *l;
-  htab_up htab (htab_create_alloc (13, htab_hash_string, htab_eq_string, NULL,
-				   xcalloc, xfree));
+
+  using traits = gdb::libiberty_traits<htab_hash_string, htab_eq_string,
+				       const char *>;
+  gdb::traited_hash_table<traits> htab;
 
   for (l = loc; l != NULL; l = l->next)
     {
-      const char **slot;
       const char *name = l->function_name.get ();
 
       /* Allow for some names to be NULL, ignore them.  */
       if (name == NULL)
 	continue;
 
-      slot = (const char **) htab_find_slot (htab.get (), (const void *) name,
-					     INSERT);
-      /* NOTE: We can assume slot != NULL here because xcalloc never
-	 returns NULL.  */
-      if (*slot != NULL)
+      if (!htab.insert (name).second)
 	return true;
-      *slot = name;
     }
 
   return false;