Commit 4aba5d42 authored by Juliusz Chroboczek's avatar Juliusz Chroboczek

Free routes table when all routes get flushed.

parent 938b89b1
...@@ -93,7 +93,11 @@ flush_route(struct route *route) ...@@ -93,7 +93,11 @@ flush_route(struct route *route)
numroutes--; numroutes--;
VALGRIND_MAKE_MEM_UNDEFINED(routes + numroutes, sizeof(struct route)); VALGRIND_MAKE_MEM_UNDEFINED(routes + numroutes, sizeof(struct route));
if(maxroutes > 8 && numroutes < maxroutes / 4) { if(numroutes == 0) {
free(routes);
routes = NULL;
maxroutes = 0;
} else if(maxroutes > 8 && numroutes < maxroutes / 4) {
struct route *new_routes; struct route *new_routes;
int n = maxroutes / 2; int n = maxroutes / 2;
new_routes = realloc(routes, n * sizeof(struct route)); new_routes = realloc(routes, n * sizeof(struct route));
......
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