diff options
-rw-r--r-- | include/ChangeLog | 5 | ||||
-rw-r--r-- | include/splay-tree.h | 4 | ||||
-rw-r--r-- | libiberty/ChangeLog | 5 | ||||
-rw-r--r-- | libiberty/splay-tree.c | 19 |
4 files changed, 32 insertions, 1 deletions
diff --git a/include/ChangeLog b/include/ChangeLog index 8b303bd..5693a3e 100644 --- a/include/ChangeLog +++ b/include/ChangeLog @@ -1,3 +1,8 @@ +2018-05-28 Bernd Edlinger <bernd.edlinger@hotmail.de> + + * splay-tree.h (splay_tree_compare_strings, + splay_tree_delete_pointers): Declare new utility functions. + 2018-05-21 Peter Bergner <bergner@vnet.ibm.com.com> * opcode/ppc.h (PPC_OPERAND_FAKE): Delete macro. diff --git a/include/splay-tree.h b/include/splay-tree.h index b63612c..fc94fb7 100644 --- a/include/splay-tree.h +++ b/include/splay-tree.h @@ -147,7 +147,9 @@ extern splay_tree_node splay_tree_max (splay_tree); extern splay_tree_node splay_tree_min (splay_tree); extern int splay_tree_foreach (splay_tree, splay_tree_foreach_fn, void*); extern int splay_tree_compare_ints (splay_tree_key, splay_tree_key); -extern int splay_tree_compare_pointers (splay_tree_key, splay_tree_key); +extern int splay_tree_compare_pointers (splay_tree_key, splay_tree_key); +extern int splay_tree_compare_strings (splay_tree_key, splay_tree_key); +extern void splay_tree_delete_pointers (splay_tree_value); #ifdef __cplusplus } diff --git a/libiberty/ChangeLog b/libiberty/ChangeLog index b249226..19c6269 100644 --- a/libiberty/ChangeLog +++ b/libiberty/ChangeLog @@ -1,3 +1,8 @@ +2018-05-28 Bernd Edlinger <bernd.edlinger@hotmail.de> + + * splay-tree.c (splay_tree_compare_strings, + splay_tree_delete_pointers): New utility functions. + 2018-05-10 Martin Liska <mliska@suse.cz> PR bootstrap/64914 diff --git a/libiberty/splay-tree.c b/libiberty/splay-tree.c index 23d22a8..d3be4aa 100644 --- a/libiberty/splay-tree.c +++ b/libiberty/splay-tree.c @@ -31,6 +31,9 @@ Boston, MA 02110-1301, USA. */ #ifdef HAVE_STDLIB_H #include <stdlib.h> #endif +#ifdef HAVE_STRING_H +#include <string.h> +#endif #include <stdio.h> @@ -590,3 +593,19 @@ splay_tree_compare_pointers (splay_tree_key k1, splay_tree_key k2) else return 0; } + +/* Splay-tree comparison function, treating the keys as strings. */ + +int +splay_tree_compare_strings (splay_tree_key k1, splay_tree_key k2) +{ + return strcmp ((char *) k1, (char *) k2); +} + +/* Splay-tree delete function, simply using free. */ + +void +splay_tree_delete_pointers (splay_tree_value value) +{ + free ((void *) value); +} |