From 4fb498c9b303e346f5279a9c8f2f7f59b60c6fcc Mon Sep 17 00:00:00 2001 From: c9s Date: Thu, 15 May 2014 18:28:33 +0800 Subject: [PATCH] basic radix tree for route patterns --- include/node.h | 2 ++ tests/test_tree.c | 6 +++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/include/node.h b/include/node.h index 1535fd6..73a374a 100644 --- a/include/node.h +++ b/include/node.h @@ -43,6 +43,8 @@ rnode * rnode_insert_routel(rnode *tree, char *route, int route_len); void rnode_dump(rnode * n, int level); +rnode * rnode_lookup(rnode * tree, char * path, int path_len); + redge * redge_create(char * pattern, int pattern_len, rnode * child); void redge_free(redge * edge); diff --git a/tests/test_tree.c b/tests/test_tree.c index eb89713..fbb2e28 100644 --- a/tests/test_tree.c +++ b/tests/test_tree.c @@ -66,9 +66,9 @@ START_TEST (test_rnode_insert_tokens) rnode_dump(n, 0); - fail_if( rnode_lookup(n, "/a/jj/kk", strlen("/a/jj/kk") ) == NULL ); - fail_if( rnode_lookup(n, "/a/jj", strlen("/a/jj") ) != NULL ); - fail_if( rnode_lookup(n, "/a/jj/kk/ll", strlen("/a/jj/kk/ll") ) != NULL ); + fail_if( rnode_lookup(n , "/a/jj/kk" , strlen("/a/jj/kk") ) == NULL ); + fail_if( rnode_lookup(n , "/a/jj" , strlen("/a/jj") ) != NULL ); + fail_if( rnode_lookup(n , "/a/jj/kk/ll" , strlen("/a/jj/kk/ll") ) != NULL ); fail_if( rnode_lookup(n, "/xxxx", strlen("xxxx") ) != NULL );