libext2fs: remove pointless indirection in rbtree bitmaps

The code was previously allocating a single 4 or 8 byte pointer for
the rcursor and wcursor fields in the ext2fs_rb_private structure;
this added two extra memory allocations (which could fail), and extra
indirections, for no good reason.  Removing the extra indirection also
makes the code more readable, so it's all upside and no downside.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Reviewed-by: Eric Sandeen <sandeen@redhat.com>
diff --git a/lib/ext2fs/blkmap64_rb.c b/lib/ext2fs/blkmap64_rb.c
index c9006f8..900c0d3 100644
--- a/lib/ext2fs/blkmap64_rb.c
+++ b/lib/ext2fs/blkmap64_rb.c
@@ -38,8 +38,8 @@
 
 struct ext2fs_rb_private {
 	struct rb_root root;
-	struct bmap_rb_extent **wcursor;
-	struct bmap_rb_extent **rcursor;
+	struct bmap_rb_extent *wcursor;
+	struct bmap_rb_extent *rcursor;
 #ifdef BMAP_STATS_OPS
 	__u64 mark_hit;
 	__u64 test_hit;
@@ -148,10 +148,10 @@
 static void rb_free_extent(struct ext2fs_rb_private *bp,
 			   struct bmap_rb_extent *ext)
 {
-	if (*bp->wcursor == ext)
-		*bp->wcursor = NULL;
-	if (*bp->rcursor == ext)
-		*bp->rcursor = NULL;
+	if (bp->wcursor == ext)
+		bp->wcursor = NULL;
+	if (bp->rcursor == ext)
+		bp->rcursor = NULL;
 	ext2fs_free_mem(&ext);
 }
 
@@ -165,14 +165,8 @@
 		return retval;
 
 	bp->root = RB_ROOT;
-	retval = ext2fs_get_mem(sizeof(struct bmap_rb_extent *), &bp->rcursor);
-	if (retval)
-		return retval;
-	retval = ext2fs_get_mem(sizeof(struct bmap_rb_extent *), &bp->wcursor);
-	if (retval)
-		return retval;
-	*bp->rcursor = NULL;
-	*bp->wcursor = NULL;
+	bp->rcursor = NULL;
+	bp->wcursor = NULL;
 
 #ifdef BMAP_STATS_OPS
 	bp->test_hit = 0;
@@ -215,8 +209,6 @@
 	bp = (struct ext2fs_rb_private *) bitmap->private;
 
 	rb_free_tree(&bp->root);
-	ext2fs_free_mem(&bp->rcursor);
-	ext2fs_free_mem(&bp->wcursor);
 	ext2fs_free_mem(&bp);
 	bp = 0;
 }
@@ -235,8 +227,8 @@
 
 	src_bp = (struct ext2fs_rb_private *) src->private;
 	dest_bp = (struct ext2fs_rb_private *) dest->private;
-	*src_bp->rcursor = NULL;
-	*dest_bp->rcursor = NULL;
+	src_bp->rcursor = NULL;
+	dest_bp->rcursor = NULL;
 
 	src_node = ext2fs_rb_first(&src_bp->root);
 	while (src_node) {
@@ -299,8 +291,8 @@
 	}
 
 	bp = (struct ext2fs_rb_private *) bmap->private;
-	*bp->rcursor = NULL;
-	*bp->wcursor = NULL;
+	bp->rcursor = NULL;
+	bp->wcursor = NULL;
 
 	/* truncate tree to new_real_end size */
 	rb_truncate(new_real_end, &bp->root);
@@ -319,7 +311,7 @@
 	struct rb_node **n = &bp->root.rb_node;
 	struct bmap_rb_extent *ext;
 
-	rcursor = *bp->rcursor;
+	rcursor = bp->rcursor;
 	if (!rcursor)
 		goto search_tree;
 
@@ -342,7 +334,7 @@
 		}
 	}
 
-	rcursor = *bp->wcursor;
+	rcursor = bp->wcursor;
 	if (!rcursor)
 		goto search_tree;
 
@@ -359,7 +351,7 @@
 		else if (bit >= (ext->start + ext->count))
 			n = &(*n)->rb_right;
 		else {
-			*bp->rcursor = ext;
+			bp->rcursor = ext;
 			return 1;
 		}
 	}
@@ -376,7 +368,7 @@
 	struct bmap_rb_extent *ext;
 	int retval = 0;
 
-	ext = *bp->wcursor;
+	ext = bp->wcursor;
 	if (ext) {
 		if (start >= ext->start &&
 		    start <= (ext->start + ext->count)) {
@@ -419,7 +411,7 @@
 	new_node = &new_ext->node;
 	ext2fs_rb_link_node(new_node, parent, n);
 	ext2fs_rb_insert_color(new_node, root);
-	*bp->wcursor = new_ext;
+	bp->wcursor = new_ext;
 
 	node = ext2fs_rb_prev(new_node);
 	if (node) {
@@ -745,8 +737,8 @@
 	bp = (struct ext2fs_rb_private *) bitmap->private;
 
 	rb_free_tree(&bp->root);
-	*bp->rcursor = NULL;
-	*bp->wcursor = NULL;
+	bp->rcursor = NULL;
+	bp->wcursor = NULL;
 }
 
 #ifdef BMAP_STATS