diff options
author | Daniel Lezcano <daniel.lezcano@linaro.org> | 2011-06-08 23:30:00 +0200 |
---|---|---|
committer | Daniel Lezcano <daniel.lezcano@free.fr> | 2011-06-08 23:30:00 +0200 |
commit | 357dd8afb93fc6e08073ce7608107dc5f44fc853 (patch) | |
tree | a3307679f4e674149929d20f26d120a25a0d6e8b /tree.c | |
parent | 7801c2de6ab4407368dbc76adb685e206caac961 (diff) | |
download | powerdebug-357dd8afb93fc6e08073ce7608107dc5f44fc853.tar.gz |
add 'find' function for the tree
That will be useful to search for a specific node name.
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
Diffstat (limited to 'tree.c')
-rw-r--r-- | tree.c | 17 |
1 files changed, 17 insertions, 0 deletions
@@ -223,3 +223,20 @@ int tree_for_each(struct tree *tree, tree_cb_t cb, void *data) return tree_for_each(tree->next, cb, data); } + +struct tree *tree_find(struct tree *tree, const char *name) +{ + struct tree *t; + + if (!tree) + return NULL; + + if (!strcmp(tree->name, name)) + return tree; + + t = tree_find(tree->child, name); + if (t) + return t; + + return tree_find(tree->next, name); +} |