[2/9] Use htab_up in breakpoint.c

Message ID 20200718172915.6811-3-tom@tromey.com
State New
Headers show
Series
  • Use htab_up in more places
Related show

Commit Message

Tom Tromey July 18, 2020, 5:29 p.m.
This changes breakpoint.c to use htab_up rather than an explicit
htab_delete.  This simplifies the code somewhat.

gdb/ChangeLog
2020-07-18  Tom Tromey  <tom@tromey.com>

	* breakpoint.c (ambiguous_names_p): Use htab_up.
---
 gdb/ChangeLog    |  4 ++++
 gdb/breakpoint.c | 12 ++++--------
 2 files changed, 8 insertions(+), 8 deletions(-)

-- 
2.17.2

Patch

diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c
index 6d81323dd92..0dd9aa39522 100644
--- a/gdb/breakpoint.c
+++ b/gdb/breakpoint.c
@@ -13257,8 +13257,8 @@  static int
 ambiguous_names_p (struct bp_location *loc)
 {
   struct bp_location *l;
-  htab_t htab = htab_create_alloc (13, htab_hash_string, streq_hash, NULL,
-				   xcalloc, xfree);
+  htab_up htab (htab_create_alloc (13, htab_hash_string, streq_hash, NULL,
+				   xcalloc, xfree));
 
   for (l = loc; l != NULL; l = l->next)
     {
@@ -13269,19 +13269,15 @@  ambiguous_names_p (struct bp_location *loc)
       if (name == NULL)
 	continue;
 
-      slot = (const char **) htab_find_slot (htab, (const void *) name,
+      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)
-	{
-	  htab_delete (htab);
-	  return 1;
-	}
+	return 1;
       *slot = name;
     }
 
-  htab_delete (htab);
   return 0;
 }