Commit fd3ac774 authored by Juliusz Chroboczek's avatar Juliusz Chroboczek

Realloc xroutes when the number of xroutes shrinks a lot.

parent 72480049
...@@ -65,6 +65,15 @@ flush_xroute(struct xroute *xroute) ...@@ -65,6 +65,15 @@ flush_xroute(struct xroute *xroute)
memcpy(xroutes + n, xroutes + numxroutes - 1, sizeof(struct xroute)); memcpy(xroutes + n, xroutes + numxroutes - 1, sizeof(struct xroute));
numxroutes--; numxroutes--;
VALGRIND_MAKE_MEM_UNDEFINED(xroutes + numxroutes, sizeof(struct xroute)); VALGRIND_MAKE_MEM_UNDEFINED(xroutes + numxroutes, sizeof(struct xroute));
if(maxxroutes > 8 && numxroutes < maxxroutes / 4) {
struct xroute *new_xroutes;
int n = maxxroutes / 2;
new_xroutes = realloc(xroutes, n * sizeof(struct xroute));
if(new_xroutes == NULL)
return;
xroutes = new_xroutes;
}
} }
int int
......
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