]> granicus.if.org Git - graphviz/commitdiff
better memory management of static cycles variable (free it before swapping it)
authorBilly Schoenberg <bschoenberg@bschoenberg.local>
Mon, 28 Jan 2019 14:33:09 +0000 (09:33 -0500)
committerBilly Schoenberg <bschoenberg@bschoenberg.local>
Mon, 28 Jan 2019 14:33:09 +0000 (09:33 -0500)
lib/common/routespl.c

index 6abf72ea1efec05a1520864a3be4c1d86db9d3bb..4c2b29a4253ae6077f11ac2cbb8f72c52b4434a5 100644 (file)
@@ -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;
        }