[uClibc-cvs] uClibc/libc/misc/search Makefile, 1.2, 1.3 tsearch.c, 1.1, 1.2

Erik Andersen andersen at uclibc.org
Sat Sep 6 00:32:06 UTC 2003


Update of /var/cvs/uClibc/libc/misc/search
In directory winder:/tmp/cvs-serv20739/libc/misc/search

Modified Files:
	Makefile tsearch.c 
Log Message:
Fix the bugs I stupidly added


Index: tsearch.c
===================================================================
RCS file: /var/cvs/uClibc/libc/misc/search/tsearch.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- tsearch.c	2 Dec 2002 16:20:50 -0000	1.1
+++ tsearch.c	6 Sep 2003 00:32:02 -0000	1.2
@@ -28,6 +28,7 @@
  */
 /*LINTLIBRARY*/
 
+#define _GNU_SOURCE
 #include <search.h>
 #include <stdlib.h>
 
@@ -187,4 +188,30 @@
 }
 #endif
 
+#ifdef L_tdestroy
+/* The standardized functions miss an important functionality: the
+   tree cannot be removed easily.  We provide a function to do this.  */
+static void
+internal_function
+tdestroy_recurse (node *root, __free_fn_t freefct)
+{
+    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);
+}
+
+void tdestroy (void *vroot, __free_fn_t freefct)
+{
+    node *root = (node *) vroot;
+    if (root != NULL) {
+	tdestroy_recurse (root, freefct);
+    }
+}
+#endif
+
 /* tsearch.c ends here */
+

Index: Makefile
===================================================================
RCS file: /var/cvs/uClibc/libc/misc/search/Makefile,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- Makefile	2 Dec 2002 16:34:56 -0000	1.2
+++ Makefile	6 Sep 2003 00:32:02 -0000	1.3
@@ -25,7 +25,7 @@
 include $(TOPDIR)Rules.mak
 
 MSRC1=tsearch.c
-MOBJ1=tsearch.o tfind.o tdelete.o twalk.o
+MOBJ1=tsearch.o tfind.o tdelete.o twalk.o tdestroy.o
 
 MSRC2=lsearch.c
 MOBJ2=lfind.o lsearch.o




More information about the uClibc-cvs mailing list