From 2698f5ead62298979e44a212023027ebb582f3d1 Mon Sep 17 00:00:00 2001 From: Tom Tromey Date: Fri, 7 May 2021 09:18:18 -0600 Subject: [PATCH] Remove streq_hash in favor of htab_eq_string Now that libiberty includes htab_eq_string, we can remove the identical function from gdb. gdb/ChangeLog 2021-05-07 Tom Tromey * breakpoint.c (ambiguous_names_p): Use htab_eq_string. * utils.c (streq_hash): Remove. * utils.h (streq_hash): Don't declare. * completer.c (completion_tracker::discard_completions): Update comment. * ada-lang.c (_initialize_ada_language): Use htab_eq_string. --- gdb/ChangeLog | 9 +++++++++ gdb/ada-lang.c | 3 ++- gdb/breakpoint.c | 2 +- gdb/completer.c | 2 +- gdb/utils.c | 8 -------- gdb/utils.h | 5 ----- 6 files changed, 13 insertions(+), 16 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 45b048da4f5..76ccb6beb3c 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,12 @@ +2021-05-07 Tom Tromey + + * breakpoint.c (ambiguous_names_p): Use htab_eq_string. + * utils.c (streq_hash): Remove. + * utils.h (streq_hash): Don't declare. + * completer.c (completion_tracker::discard_completions): Update + comment. + * ada-lang.c (_initialize_ada_language): Use htab_eq_string. + 2021-05-07 Simon Marchi * Re-format all Python files using black. diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c index e15e583adca..34b0e925685 100644 --- a/gdb/ada-lang.c +++ b/gdb/ada-lang.c @@ -13490,7 +13490,8 @@ When enabled, the debugger will stop using the DW_AT_GNAT_descriptive_type\n\ DWARF attribute."), NULL, NULL, &maint_set_ada_cmdlist, &maint_show_ada_cmdlist); - decoded_names_store = htab_create_alloc (256, htab_hash_string, streq_hash, + decoded_names_store = htab_create_alloc (256, htab_hash_string, + htab_eq_string, NULL, xcalloc, xfree); /* The ada-lang observers. */ diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c index 35a891bb4b9..38406b45856 100644 --- a/gdb/breakpoint.c +++ b/gdb/breakpoint.c @@ -13471,7 +13471,7 @@ static int ambiguous_names_p (struct bp_location *loc) { struct bp_location *l; - htab_up htab (htab_create_alloc (13, htab_hash_string, streq_hash, NULL, + htab_up htab (htab_create_alloc (13, htab_hash_string, htab_eq_string, NULL, xcalloc, xfree)); for (l = loc; l != NULL; l = l->next) diff --git a/gdb/completer.c b/gdb/completer.c index 2330ad435a8..80e8c7b743e 100644 --- a/gdb/completer.c +++ b/gdb/completer.c @@ -1593,7 +1593,7 @@ completion_tracker::discard_completions () m_entries_hash.reset (nullptr); /* A callback used by the hash table to compare new entries with existing - entries. We can't use the standard streq_hash function here as the + entries. We can't use the standard htab_eq_string function here as the key to our hash is just a single string, while the values we store in the hash are a struct containing multiple strings. */ static auto entry_eq_func diff --git a/gdb/utils.c b/gdb/utils.c index b9f8997ec80..1f48a5a0bfe 100644 --- a/gdb/utils.c +++ b/gdb/utils.c @@ -2818,14 +2818,6 @@ streq (const char *lhs, const char *rhs) return !strcmp (lhs, rhs); } -/* See utils.h. */ - -int -streq_hash (const void *lhs, const void *rhs) -{ - return streq ((const char *) lhs, (const char *) rhs); -} - /* diff --git a/gdb/utils.h b/gdb/utils.h index b91e0d1ea34..94d37c5a8b1 100644 --- a/gdb/utils.h +++ b/gdb/utils.h @@ -99,11 +99,6 @@ extern int strcmp_iw_ordered (const char *, const char *); extern bool streq (const char *, const char *); -/* A variant of streq that is suitable for use as an htab - callback. */ - -extern int streq_hash (const void *, const void *); - extern int subset_compare (const char *, const char *); /* Compare C strings for std::sort. */ -- 2.30.2