Commit 40b926ef authored by Juliusz Chroboczek's avatar Juliusz Chroboczek

Reallocate routes when the table shrinks a lot.

parent e7aad3be
......@@ -93,6 +93,15 @@ flush_route(struct route *route)
numroutes--;
VALGRIND_MAKE_MEM_UNDEFINED(routes + numroutes, sizeof(struct route));
if(maxroutes > 8 && numroutes < maxroutes / 4) {
struct route *new_routes;
int n = maxroutes / 2;
new_routes = realloc(routes, n * sizeof(struct route));
if(new_routes == NULL)
return;
routes = new_routes;
}
if(lost)
route_lost(src, oldmetric);
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment