Fix gnu c compiler error when the variable is the same
This commit is contained in:
parent
fd4e89c2f4
commit
5331d375ac
1 changed files with 12 additions and 7 deletions
17
src/node.c
17
src/node.c
|
@ -54,8 +54,10 @@ void r3_tree_free(node * tree) {
|
||||||
free(tree->pcre_extra);
|
free(tree->pcre_extra);
|
||||||
if (tree->ov)
|
if (tree->ov)
|
||||||
free(tree->ov);
|
free(tree->ov);
|
||||||
|
if (tree->edges)
|
||||||
free(tree->edges);
|
free(tree->edges);
|
||||||
// str_array_free(tree->edge_patterns);
|
if (tree->routes)
|
||||||
|
free(tree->routes);
|
||||||
free(tree);
|
free(tree);
|
||||||
tree = NULL;
|
tree = NULL;
|
||||||
}
|
}
|
||||||
|
@ -89,7 +91,10 @@ void r3_node_append_edge(node *n, edge *e) {
|
||||||
}
|
}
|
||||||
if (n->edge_len >= n->edge_cap) {
|
if (n->edge_len >= n->edge_cap) {
|
||||||
n->edge_cap *= 2;
|
n->edge_cap *= 2;
|
||||||
n->edges = realloc(n->edges, sizeof(edge) * n->edge_cap);
|
edge ** p = realloc(n->edges, sizeof(edge) * n->edge_cap);
|
||||||
|
if(p) {
|
||||||
|
n->edges = p;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
n->edges[ n->edge_len++ ] = e;
|
n->edges[ n->edge_len++ ] = e;
|
||||||
}
|
}
|
||||||
|
@ -570,16 +575,16 @@ int r3_route_cmp(route *r1, match_entry *r2) {
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
void r3_node_append_route(node * n, route * route) {
|
void r3_node_append_route(node * n, route * r) {
|
||||||
if (!n->routes) {
|
if (!n->routes) {
|
||||||
n->route_cap = 3;
|
n->route_cap = 3;
|
||||||
n->routes = malloc(sizeof(route) * n->route_cap);
|
n->routes = malloc(sizeof(r) * n->route_cap);
|
||||||
}
|
}
|
||||||
if (n->route_len >= n->route_cap) {
|
if (n->route_len >= n->route_cap) {
|
||||||
n->route_cap *= 2;
|
n->route_cap *= 2;
|
||||||
n->routes = realloc(n->routes, sizeof(route) * n->route_cap);
|
n->routes = realloc(n->routes, sizeof(r) * n->route_cap);
|
||||||
}
|
}
|
||||||
n->routes[ n->route_len++ ] = route;
|
n->routes[ n->route_len++ ] = r;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue