From 97811bd35bed364f76d076eca0e16d40db8da8fb Mon Sep 17 00:00:00 2001 From: Billy Schoenberg Date: Mon, 28 Jan 2019 09:33:09 -0500 Subject: [PATCH] better memory management of static cycles variable (free it before swapping it) --- lib/common/routespl.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lib/common/routespl.c b/lib/common/routespl.c index 6abf72ea1..4c2b29a42 100644 --- a/lib/common/routespl.c +++ b/lib/common/routespl.c @@ -1109,6 +1109,14 @@ static pointf get_cycle_centroid(graph_t *g, edge_t* edge) static graph_t* ref_g = 0; if (cycles == 0 || ref_g != g) { + //free the memory we're using to hold the previous cycles + if (cycles != 0) { + size_t i; + for (i=0; i < vec_length(cycles); ++i) { + vec_delete(vec_get(cycles, i)); + } + vec_delete(cycles); + } cycles = find_all_cycles(g); ref_g = g; } -- 2.40.0