]> granicus.if.org Git - graphviz/commitdiff
dotgen _dot_splines: remove unnecessary dynamic allocation of 'P'
authorMatthew Fernandez <matthew.fernandez@gmail.com>
Fri, 23 Dec 2022 22:06:11 +0000 (14:06 -0800)
committerMatthew Fernandez <matthew.fernandez@gmail.com>
Sat, 24 Dec 2022 17:52:53 +0000 (09:52 -0800)
lib/dotgen/dotsplines.c

index 901b23371c41bb3796a2a6a68ea46ab6ff493343..acd86a2eccb3c661d67bc5a76b5257b941540aa1 100644 (file)
@@ -267,7 +267,7 @@ static void _dot_splines(graph_t * g, int normalize)
     Agedgeinfo_t fwdedgeai, fwdedgebi;
     Agedgepair_t fwdedgea, fwdedgeb;
     edge_t *e, *e0, *e1, *ea, *eb, *le0, *le1, **edges = NULL;
-    path *P = NULL;
+    path P = {0};
     spline_info_t sd;
     int et = EDGE_TYPE(g);
     fwdedgea.out.base.data = (Agrec_t*)&fwdedgeai;
@@ -297,7 +297,6 @@ static void _dot_splines(graph_t * g, int normalize)
 
     mark_lowclusters(g);
     if (routesplinesinit()) return;
-    P = gv_alloc(sizeof(path));
     /* FlatHeight = 2 * GD_nodesep(g); */
     sd.Splinesep = GD_nodesep(g) / 4;
     sd.Multisep = GD_nodesep(g);
@@ -373,7 +372,7 @@ static void _dot_splines(graph_t * g, int normalize)
     qsort(edges, n_edges, sizeof(edges[0]), (qsort_cmpf)edgecmp);
 
     /* FIXME: just how many boxes can there be? */
-    P->boxes = gv_calloc(n_nodes + 20 * 2 * NSUB, sizeof(boxf));
+    P.boxes = gv_calloc(n_nodes + 20 * 2 * NSUB, sizeof(boxf));
     sd.Rank_box = gv_calloc(i, sizeof(boxf));
 
     if (et == EDGETYPE_LINE) {
@@ -463,10 +462,10 @@ static void _dot_splines(graph_t * g, int normalize)
            }
        }
        else if (ND_rank(agtail(e0)) == ND_rank(aghead(e0))) {
-           make_flat_edge(g, &sd, P, edges, ind, cnt, et);
+           make_flat_edge(g, &sd, &P, edges, ind, cnt, et);
        }
        else
-           make_regular_edge(g, &sd, P, edges, ind, cnt, et);
+           make_regular_edge(g, &sd, &P, edges, ind, cnt, et);
     }
 
     /* place regular edge labels */
@@ -515,8 +514,7 @@ finish :
     if (et != EDGETYPE_CURVED) {
 #endif
        free(edges);
-       free(P->boxes);
-       free(P);
+       free(P.boxes);
        free(sd.Rank_box);
        routesplinesterm();
     }