Fix gnu c compiler error when the variable is the same

This commit is contained in:
c9s 2014-05-20 15:32:22 +08:00
parent fd4e89c2f4
commit 5331d375ac

View file

@ -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);
free(tree->edges); if (tree->edges)
// str_array_free(tree->edge_patterns); free(tree->edges);
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;
} }