mirror of
https://github.com/espressif/binutils-gdb.git
synced 2025-06-19 00:59:15 +08:00
libiberty: add htab_eq_string
The libiberty hash table includes a helper function for strings, but no equality function. Consequently, this equality function has been reimplemented a number of times in both the gcc and binutils-gdb source trees. This patch adds the function to the libiberty hash table, as a step toward the goal of removing all the copies. One change to gcc is included here. Normally I would have put this in the next patch, but gensupport.c used the most natural name for its reimplementation of this function, and this can't coexist with the extern function in libiberty. include * hashtab.h (htab_eq_string): Declare. libiberty * hashtab.c (htab_eq_string): New function.
This commit is contained in:

committed by
Richard Earnshaw

parent
4cf88725da
commit
c759c777c9
@ -841,6 +841,13 @@ htab_hash_string (const PTR p)
|
||||
return r;
|
||||
}
|
||||
|
||||
/* An equality function for null-terminated strings. */
|
||||
int
|
||||
htab_eq_string (const void *a, const void *b)
|
||||
{
|
||||
return strcmp ((const char *) a, (const char *) b) == 0;
|
||||
}
|
||||
|
||||
/* DERIVED FROM:
|
||||
--------------------------------------------------------------------
|
||||
lookup2.c, by Bob Jenkins, December 1996, Public Domain.
|
||||
|
Reference in New Issue
Block a user