about summary refs log tree commit diff
path: root/misc
diff options
context:
space:
mode:
Diffstat (limited to 'misc')
-rw-r--r--misc/tsearch.c16
-rw-r--r--misc/tst-tsearch.c8
2 files changed, 10 insertions, 14 deletions
diff --git a/misc/tsearch.c b/misc/tsearch.c
index c06930d509..e372a9e971 100644
--- a/misc/tsearch.c
+++ b/misc/tsearch.c
@@ -85,6 +85,7 @@
    binary tree.  */
 
 #include <stdlib.h>
+#include <string.h>
 #include <search.h>
 
 typedef struct node_t
@@ -633,16 +634,11 @@ weak_alias (__twalk, twalk)
 static void
 tdestroy_recurse (node root, __free_fn_t freefct)
 {
-  if (root->left == NULL && root->right == NULL)
-    (*freefct) (root->key);
-  else
-    {
-      if (root->left != NULL)
-	tdestroy_recurse (root->left, freefct);
-      if (root->right != NULL)
-	tdestroy_recurse (root->right, freefct);
-      (*freefct) (root->key);
-    }
+  if (root->left != NULL)
+    tdestroy_recurse (root->left, freefct);
+  if (root->right != NULL)
+    tdestroy_recurse (root->right, freefct);
+  (*freefct) ((void *) root->key);
   /* Free the node itself.  */
   free (root);
 }
diff --git a/misc/tst-tsearch.c b/misc/tst-tsearch.c
index 18cf89c91f..7a0c5fac6e 100644
--- a/misc/tst-tsearch.c
+++ b/misc/tst-tsearch.c
@@ -197,14 +197,14 @@ mangle_tree (enum order how, enum action what, void **root, int lag)
 	case build:
 	  if (i < SIZE)
 	    {
-	      if (tfind (x + j, (const void **) root, cmp_fn) != NULL)
+	      if (tfind (x + j, (void *const *) root, cmp_fn) != NULL)
 		{
 		  fputs ("Found element which is not in tree yet.\n", stdout);
 		  error = 1;
 		}
 	      elem = tsearch (x + j, root, cmp_fn);
 	      if (elem == 0
-		  || tfind (x + j, (const void **) root, cmp_fn) == NULL)
+		  || tfind (x + j, (void *const *) root, cmp_fn) == NULL)
 		{
 		  fputs ("Couldn't find element after it was added.\n",
 			 stdout);
@@ -219,7 +219,7 @@ mangle_tree (enum order how, enum action what, void **root, int lag)
 	  /* fall through */
 
 	case delete:
-	  elem = tfind (x + j, (const void **) root, cmp_fn);
+	  elem = tfind (x + j, (void *const *) root, cmp_fn);
 	  if (elem == NULL || tdelete (x + j, root, cmp_fn) == NULL)
 	    {
 	      fputs ("Error deleting element.\n", stdout);
@@ -228,7 +228,7 @@ mangle_tree (enum order how, enum action what, void **root, int lag)
 	  break;
 
 	case find:
-	  if (tfind (x + j, (const void **) root, cmp_fn) == NULL)
+	  if (tfind (x + j, (void *const *) root, cmp_fn) == NULL)
 	    {
 	      fputs ("Couldn't find element after it was added.\n", stdout);
 	      error = 1;