From: Billy Schoenberg Date: Mon, 28 Jan 2019 14:33:09 +0000 (-0500) Subject: better memory management of static cycles variable (free it before swapping it) X-Git-Tag: 2.42.0~14^2 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=97811bd35bed364f76d076eca0e16d40db8da8fb;p=graphviz better memory management of static cycles variable (free it before swapping it) --- 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; }