[GRASS-SVN] r43595 - grass/trunk/lib/btree2

svn_grass at osgeo.org svn_grass at osgeo.org
Tue Sep 21 10:15:26 EDT 2010


Author: mmetz
Date: 2010-09-21 14:15:26 +0000 (Tue, 21 Sep 2010)
New Revision: 43595

Modified:
   grass/trunk/lib/btree2/rbtree.c
Log:
compact and format code

Modified: grass/trunk/lib/btree2/rbtree.c
===================================================================
--- grass/trunk/lib/btree2/rbtree.c	2010-09-21 14:13:39 UTC (rev 43594)
+++ grass/trunk/lib/btree2/rbtree.c	2010-09-21 14:15:26 UTC (rev 43595)
@@ -409,16 +409,16 @@
 /* destroy the tree */
 void rbtree_destroy(struct RB_TREE *tree)
 {
-    struct RB_NODE *it = tree->root;
-    struct RB_NODE *save;
+    struct RB_NODE *it;
+    struct RB_NODE *save = tree->root;
 
     /*
     Rotate away the left links so that
     we can treat this like the destruction
     of a linked list
     */
-    while ( it != NULL ) {
-	if ( it->link[0] == NULL ) {
+    while((it = save) != NULL) {
+	if (it->link[0] == NULL) {
 	    /* No left links, just kill the node and move on */
 	    save = it->link[1];
 	    free(it->data);
@@ -430,11 +430,8 @@
 	    it->link[0] = save->link[1];
 	    save->link[1] = it;
 	}
-
-	it = save;
     }
-
-  free(tree);
+    free(tree);
 }
 
 /* used for debugging: check for errors in tree structure */



More information about the grass-commit mailing list