diff mbox

[25/28] compute the number of children for a specific node

Message ID 1308256197-29155-25-git-send-email-daniel.lezcano@linaro.org
State Accepted
Headers show

Commit Message

Daniel Lezcano June 16, 2011, 8:29 p.m. UTC
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
---
 tree.c |    3 +++
 tree.h |    1 +
 2 files changed, 4 insertions(+), 0 deletions(-)
diff mbox

Patch

diff --git a/tree.c b/tree.c
index 8f546a9..dd53ff2 100644
--- a/tree.c
+++ b/tree.c
@@ -57,6 +57,7 @@  static inline struct tree *tree_alloc(const char *path, int depth)
 	t->next = NULL;
 	t->prev = NULL;
 	t->private = NULL;
+	t->nrchild = 0;
 
 	return t;
 }
@@ -161,6 +162,8 @@  static int tree_scan(struct tree *tree, tree_filter_t filter)
 
 			tree_add_child(tree, child);
 
+			tree->nrchild++;
+
 			ret = tree_scan(child, filter);
 		}
 
diff --git a/tree.h b/tree.h
index 88d4a19..c7f3ca9 100644
--- a/tree.h
+++ b/tree.h
@@ -33,6 +33,7 @@  struct tree {
 	char *path;
 	char *name;
 	void *private;
+	int   nrchild;
 	unsigned char depth;
 };