From 9bab1bd076ec22359934c83a5bd7471ff6682b51 Mon Sep 17 00:00:00 2001 From: c9s Date: Sat, 17 May 2014 23:54:18 +0800 Subject: [PATCH] match_entry_createl --- include/r3.h | 4 +++- src/node.c | 2 +- tests/bench_str.csv | 2 ++ tests/check_tree.c | 21 +++++++++++---------- 4 files changed, 17 insertions(+), 12 deletions(-) diff --git a/include/r3.h b/include/r3.h index 0b47663..78a90f0 100644 --- a/include/r3.h +++ b/include/r3.h @@ -125,7 +125,9 @@ void r3_edge_free(edge * edge); -match_entry * match_entry_create(char * path, int path_len); +match_entry * match_entry_createl(char * path, int path_len); + +#define match_entry_create(path) match_entry_createl(path,strlen(path)) void match_entry_free(match_entry * entry); diff --git a/src/node.c b/src/node.c index 6d67a9b..08dc038 100644 --- a/src/node.c +++ b/src/node.c @@ -212,7 +212,7 @@ route_info * route_info_createl(char * path, int path_len) { return info; } -match_entry * match_entry_create(char * path, int path_len) { +match_entry * match_entry_createl(char * path, int path_len) { match_entry * entry = malloc(sizeof(match_entry)); if(!entry) return NULL; diff --git a/tests/bench_str.csv b/tests/bench_str.csv index ed47d96..2e8a5f3 100644 --- a/tests/bench_str.csv +++ b/tests/bench_str.csv @@ -57,3 +57,5 @@ 1400283485,10742869.09 1400283755,11545078.70 1400284307,11493777.72 +1400336360,10249674.13 +1400342049,10376709.43 diff --git a/tests/check_tree.c b/tests/check_tree.c index 055d4e2..cef6503 100644 --- a/tests/check_tree.c +++ b/tests/check_tree.c @@ -88,27 +88,27 @@ START_TEST (test_compile) match_entry * entry; - entry = match_entry_create( "foo" , strlen("/foo") ); + entry = match_entry_createl( "foo" , strlen("/foo") ); m = r3_tree_match( n , "/foo", strlen("/foo"), entry); fail_if( NULL == m ); - entry = match_entry_create( "/zoo" , strlen("/zoo") ); + entry = match_entry_createl( "/zoo" , strlen("/zoo") ); m = r3_tree_match( n , "/zoo", strlen("/zoo"), entry); fail_if( NULL == m ); - entry = match_entry_create( "/bar" , strlen("/bar") ); + entry = match_entry_createl( "/bar" , strlen("/bar") ); m = r3_tree_match( n , "/bar", strlen("/bar"), entry); fail_if( NULL == m ); - entry = match_entry_create( "/xxx" , strlen("/xxx") ); + entry = match_entry_createl( "/xxx" , strlen("/xxx") ); m = r3_tree_match( n , "/xxx", strlen("/xxx"), entry); fail_if( NULL == m ); - entry = match_entry_create( "/foo/xxx" , strlen("/foo/xxx") ); + entry = match_entry_createl( "/foo/xxx" , strlen("/foo/xxx") ); m = r3_tree_match( n , "/foo/xxx", strlen("/foo/xxx"), entry); fail_if( NULL == m ); - entry = match_entry_create( "/some_id" , strlen("/some_id") ); + entry = match_entry_createl( "/some_id" , strlen("/some_id") ); m = r3_tree_match( n , "/some_id", strlen("/some_id"), entry); fail_if( NULL == m ); ck_assert_int_gt( m->endpoint , 0 ); // should not be an endpoint @@ -260,13 +260,14 @@ END_TEST START_TEST(test_insert_route) { - match_entry * entry = match_entry_create(); + match_entry * entry = match_entry_createl("/blog/post", strlen("/blog/post") ); + + match_entry * entry2 = match_entry_create("/blog/post"); node * tree = r3_tree_create(2); - - route_info *info = route_info_create("/blog/post", strlen("/blog/post") ); + // route_info *info = route_info_create("/blog/post", strlen("/blog/post") ); // r3_tree_insert_route(n, "/foo/bar/baz", NULL); @@ -275,7 +276,7 @@ END_TEST START_TEST(benchmark_str) { - match_entry * entry = match_entry_create(); + match_entry * entry = match_entry_createl("/blog/post", strlen("/blog/post") ); node * n = r3_tree_create(1);