@@ -74,10 +74,13 @@ ffi_cdef[[
7474 int radix_tree_insert(void *t, const unsigned char *buf, size_t len,
7575 void *data);
7676 void *radix_tree_find(void *t, const unsigned char *buf, size_t len);
77- void *radix_tree_search(void *t, const unsigned char *buf, size_t len);
77+ void *radix_tree_search(void *t, void *it, const unsigned char *buf,
78+ size_t len);
7879 void *radix_tree_pcre(void *it, const unsigned char *buf, size_t len);
7980 void *radix_tree_next(void *it, const unsigned char *buf, size_t len);
8081 int radix_tree_stop(void *it);
82+
83+ void *radix_tree_new_it();
8184]]
8285
8386
429432
430433
431434 local matched_routes = {}
435+ local radix_it = radix .radix_tree_new_it ()
436+ if radix_it == nil then
437+ error (" failed to new radixtree it" )
438+ end
439+ -- use gc to free
440+ ffi .gc (radix_it , ffi .C .free )
441+
432442local function match_route (self , path , opts )
433443 clear_tab (matched_routes )
434444 local routes = self .hash_path [path ]
@@ -448,7 +458,7 @@ local function match_route(self, path, opts)
448458 clear_tab (matched_routes )
449459 end
450460
451- local it = radix .radix_tree_search (self .tree , path , # path )
461+ local it = radix .radix_tree_search (self .tree , radix_it , path , # path )
452462 if not it then
453463 return nil , " failed to match"
454464 end
0 commit comments