[PATCH 1/2] libctf: use htab_eq_string

Tom Tromey tom@tromey.com
Sat May 8 14:19:49 GMT 2021


Now that htab_eq_string is in libiberty, the libctf variant of this
function can be removed.

libctf/ChangeLog
2021-05-08  Tom Tromey  <tom@tromey.com>

	* ctf-hash.c (ctf_dynset_eq_string): Remove.
	* ctf-dedup.c (make_set_element, ctf_dedup_atoms_init)
	(ADD_CITER, ctf_dedup_init, ctf_dedup_conflictify_unshared)
	(ctf_dedup_walk_output_mapping): Use htab_eq_string.
	* ctf-impl.h (ctf_dynset_eq_string): Don't declare.
---
 libctf/ChangeLog   |  8 ++++++++
 libctf/ctf-dedup.c | 12 ++++++------
 libctf/ctf-hash.c  |  9 ---------
 libctf/ctf-impl.h  |  2 --
 4 files changed, 14 insertions(+), 17 deletions(-)

diff --git a/libctf/ctf-dedup.c b/libctf/ctf-dedup.c
index 649a76a91b6..520aca93b93 100644
--- a/libctf/ctf-dedup.c
+++ b/libctf/ctf-dedup.c
@@ -352,7 +352,7 @@ make_set_element (ctf_dynhash_t *set, const void *key)
   if ((element = ctf_dynhash_lookup (set, key)) == NULL)
     {
       if ((element = ctf_dynset_create (htab_hash_string,
-					ctf_dynset_eq_string,
+					htab_eq_string,
 					NULL)) == NULL)
 	return NULL;
 
@@ -376,7 +376,7 @@ ctf_dedup_atoms_init (ctf_dict_t *fp)
   if (!fp->ctf_dedup_atoms_alloc)
     {
       if ((fp->ctf_dedup_atoms_alloc
-	   = ctf_dynset_create (htab_hash_string, ctf_dynset_eq_string,
+	   = ctf_dynset_create (htab_hash_string, htab_eq_string,
 				free)) == NULL)
 	return ctf_set_errno (fp, ENOMEM);
     }
@@ -584,7 +584,7 @@ ctf_dedup_rhash_type (ctf_dict_t *fp, ctf_dict_t *input, ctf_dict_t **inputs,
       whaterr = N_("error updating citers");				\
       if (!citers)							\
 	if ((citers = ctf_dynset_create (htab_hash_string,		\
-					  ctf_dynset_eq_string,		\
+					  htab_eq_string,		\
 					  NULL)) == NULL)		\
 	  goto oom;							\
       if (ctf_dynset_cinsert (citers, hval) < 0)			\
@@ -1656,7 +1656,7 @@ ctf_dedup_init (ctf_dict_t *fp)
 
   if ((d->cd_conflicting_types
        = ctf_dynset_create (htab_hash_string,
-			    ctf_dynset_eq_string, NULL)) == NULL)
+			    htab_eq_string, NULL)) == NULL)
     goto oom;
 
   return 0;
@@ -1814,7 +1814,7 @@ ctf_dedup_conflictify_unshared (ctf_dict_t *output, ctf_dict_t **inputs)
   const void *k;
   ctf_dynset_t *to_mark = NULL;
 
-  if ((to_mark = ctf_dynset_create (htab_hash_string, ctf_dynset_eq_string,
+  if ((to_mark = ctf_dynset_create (htab_hash_string, htab_eq_string,
 				    NULL)) == NULL)
     goto err_no;
 
@@ -2351,7 +2351,7 @@ ctf_dedup_walk_output_mapping (ctf_dict_t *output, ctf_dict_t **inputs,
   void *k;
 
   if ((already_visited = ctf_dynset_create (htab_hash_string,
-					    ctf_dynset_eq_string,
+					    htab_eq_string,
 					    NULL)) == NULL)
     return ctf_set_errno (output, ENOMEM);
 
diff --git a/libctf/ctf-hash.c b/libctf/ctf-hash.c
index 426bd625ffb..73fca6fe5d2 100644
--- a/libctf/ctf-hash.c
+++ b/libctf/ctf-hash.c
@@ -140,15 +140,6 @@ ctf_hash_eq_type_id_key (const void *a, const void *b)
     && (key_a->ctii_type == key_b->ctii_type);
 }
 
-/* Hash and eq functions for the dynset.  Most of these can just use the
-   underlying hashtab functions directly.   */
-
-int
-ctf_dynset_eq_string (const void *a, const void *b)
-{
-  return !strcmp((const char *) a, (const char *) b);
-}
-
 /* The dynhash, used for hashes whose size is not known at creation time. */
 
 /* Free a single ctf_helem with arbitrary key/value functions.  */
diff --git a/libctf/ctf-impl.h b/libctf/ctf-impl.h
index 342d2ff23e2..80c47239e26 100644
--- a/libctf/ctf-impl.h
+++ b/libctf/ctf-impl.h
@@ -617,8 +617,6 @@ extern int ctf_hash_eq_string (const void *, const void *);
 extern int ctf_hash_eq_type_key (const void *, const void *);
 extern int ctf_hash_eq_type_id_key (const void *, const void *);
 
-extern int ctf_dynset_eq_string (const void *, const void *);
-
 typedef void (*ctf_hash_free_fun) (void *);
 
 typedef void (*ctf_hash_iter_f) (void *key, void *value, void *arg);
-- 
2.26.3



More information about the Binutils mailing list