Re: [PATCH 1/5] rbtree: add postorder iteration functions

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 07/29/2013 08:01 AM, Seth Jennings wrote:
On Fri, Jul 26, 2013 at 02:13:39PM -0700, Cody P Schafer wrote:
diff --git a/lib/rbtree.c b/lib/rbtree.c
index c0e31fe..65f4eff 100644
--- a/lib/rbtree.c
+++ b/lib/rbtree.c
@@ -518,3 +518,43 @@ void rb_replace_node(struct rb_node *victim, struct rb_node *new,
  	*new = *victim;
  }
  EXPORT_SYMBOL(rb_replace_node);
+
+static struct rb_node *rb_left_deepest_node(const struct rb_node *node)
+{
+	for (;;) {
+		if (node->rb_left)
+			node = node->rb_left;

Assigning to an argument passed as const seems weird to me.  I would
think it shouldn't compile but it does.  I guess my understanding of
const is incomplete.


Ya, that is due to const's binding:
	const struct rb_node *node1; // the thing pointed to is const
	const struct rb_node node2;  // node is const
	struct rb_node *const node3; // node is const
	const struct rb_node *const node4; // both node and the thing
					   // pointed too are const

And so ends up being perfectly legal (I use the first case listed here).

+		else if (node->rb_right)
+			node = node->rb_right;
+		else
+			return (struct rb_node *)node;
+	}
+}
+
+struct rb_node *rb_next_postorder(const struct rb_node *node)
+{
+	const struct rb_node *parent;
+	if (!node)
+		return NULL;
+	parent = rb_parent(node);

Again here.

Seth


--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@xxxxxxxxx.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@xxxxxxxxx";> email@xxxxxxxxx </a>




[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]