@@ -71,12 +71,11 @@ ffi_cdef[[
7171 void *radix_tree_new();
7272 int radix_tree_destroy(void *t);
7373 int radix_tree_insert(void *t, const unsigned char *buf, size_t len,
74- void *data );
74+ int idx );
7575 void *radix_tree_find(void *t, const unsigned char *buf, size_t len);
7676 void *radix_tree_search(void *t, void *it, const unsigned char *buf,
7777 size_t len);
78- void *radix_tree_pcre(void *it, const unsigned char *buf, size_t len);
79- void *radix_tree_next(void *it, const unsigned char *buf, size_t len);
78+ int radix_tree_pcre(void *it, const unsigned char *buf, size_t len);
8079 int radix_tree_stop(void *it);
8180
8281 void *radix_tree_new_it();
@@ -156,9 +155,8 @@ local function insert_route(self, opts)
156155 self .match_data_index = self .match_data_index + 1
157156 self .match_data [self .match_data_index ] = {opts }
158157
159- local dataptr = ffi_cast (' void *' , self .match_data_index )
160- radix .radix_tree_insert (self .tree , path , # path , dataptr )
161- log_info (" insert route path: " , path , " dataprt: " , tostring (dataptr ))
158+ radix .radix_tree_insert (self .tree , path , # path , self .match_data_index )
159+ log_info (" insert route path: " , path , " dataprt: " , self .match_data_index )
162160 return true
163161end
164162
@@ -467,15 +465,12 @@ local function match_route(self, path, opts)
467465 end
468466
469467 while true do
470- local data_idx = radix .radix_tree_pcre (it , path , # path )
471- log_info (" path: " , path , " data_idx: " , tostring (data_idx ))
472- if data_idx == nil then
468+ local idx = radix .radix_tree_pcre (it , path , # path )
469+ if idx <= 0 then
473470 break
474471 end
475472
476- local idx = tonumber (ffi_cast (' intptr_t' , data_idx ))
477473 routes = self .match_data [idx ]
478- -- log_info("route: ", require("cjson").encode(routes))
479474 if routes then
480475 local route = _match_from_routes (routes , path , opts )
481476 if route then
0 commit comments