From 40e0e1c2a0721033eef3a8c3a769bf9834a1036d Mon Sep 17 00:00:00 2001 From: karantin2020 Date: Tue, 8 Mar 2016 14:51:42 +0500 Subject: [PATCH] Changed slug parsing --- src/node.c | 4 +--- src/token.c | 3 +-- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/src/node.c b/src/node.c index 538c55c..8bbbde7 100644 --- a/src/node.c +++ b/src/node.c @@ -450,9 +450,7 @@ R3Route * r3_tree_match_route(const R3Node *tree, match_entry * entry) { for (i = n->route_len; i--; ) { if ( r3_route_cmp(n->routes[i], entry) == 0 ) { // Add slugs from found route to match_entry - for (int j = 0; j < n->routes[i]->slugs_len; j++) { - str_array_append_slug(entry->vars , n->routes[i]->slugs[j]); - } + entry->vars->slugs = n->routes[i]->slugs; return n->routes[i]; } } diff --git a/src/token.c b/src/token.c index 77620d2..0cefd88 100644 --- a/src/token.c +++ b/src/token.c @@ -21,7 +21,7 @@ str_array * str_array_create(int cap) { list->len = 0; list->slugs_len = 0; list->cap = cap; - list->slugs = (char**) zmalloc( sizeof(char*) * cap); + list->slugs = NULL; list->tokens = (char**) zmalloc( sizeof(char*) * cap); return list; } @@ -33,7 +33,6 @@ void str_array_free(str_array *l) { zfree(l->tokens[i]); } } - zfree(l->slugs); zfree(l->tokens); zfree(l); }