From: Matthew Fernandez Date: Fri, 18 Nov 2022 01:14:41 +0000 (-0800) Subject: fdpgen findCComp: use cgraph wrappers for allocation X-Git-Tag: 7.0.3~7^2~8 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=0e02dd1dab901fd46d4aaf4b78567e812229bf4c;p=graphviz fdpgen findCComp: use cgraph wrappers for allocation The lib/cgraph/alloc.h wrappers are similar to the older lib/common/memory.h wrappers except (1) they are header-only and (2) they live in a directory (cgraph) that is at the root of the dependency tree. The long term plan is to replace all use of lib/common/memory.h with lib/cgraph/alloc.h. --- diff --git a/lib/fdpgen/comp.c b/lib/fdpgen/comp.c index 625f384de..cf371707b 100644 --- a/lib/fdpgen/comp.c +++ b/lib/fdpgen/comp.c @@ -20,6 +20,7 @@ /* use PRIVATE interface */ #define FDP_PRIVATE 1 +#include #include #include #include @@ -61,14 +62,13 @@ graph_t **findCComp(graph_t * g, int *cnt, int *pinned) graph_t *subg; char name[128]; int c_cnt = 0; - char *marks; bport_t *pp; graph_t **comps; graph_t **cp; int pinflag = 0; /* fprintf (stderr, "comps of %s starting at %d \n", g->name, c_cnt); */ - marks = N_NEW(agnnodes(g), char); /* freed below */ + char *marks = gv_calloc(agnnodes(g), sizeof(char)); // freed below /* Create component based on port nodes */ subg = 0; @@ -76,7 +76,7 @@ graph_t **findCComp(graph_t * g, int *cnt, int *pinned) snprintf(name, sizeof(name), "cc%s_%d", agnameof(g), c_cnt++ + C_cnt); subg = agsubg(g, name,1); agbindrec(subg, "Agraphinfo_t", sizeof(Agraphinfo_t), true); - GD_alg(subg) = NEW(gdata); + GD_alg(subg) = gv_alloc(sizeof(gdata)); PORTS(subg) = pp; NPORTS(subg) = NPORTS(g); for (; pp->n; pp++) { @@ -97,7 +97,7 @@ graph_t **findCComp(graph_t * g, int *cnt, int *pinned) snprintf(name, sizeof(name), "cc%s_%d", agnameof(g), c_cnt++ + C_cnt); subg = agsubg(g, name,1); agbindrec(subg, "Agraphinfo_t", sizeof(Agraphinfo_t), true); - GD_alg(subg) = NEW(gdata); + GD_alg(subg) = gv_alloc(sizeof(gdata)); } pinflag = 1; dfs(g, n, subg, marks); @@ -112,7 +112,7 @@ graph_t **findCComp(graph_t * g, int *cnt, int *pinned) snprintf(name, sizeof(name), "cc%s+%d", agnameof(g), c_cnt++ + C_cnt); subg = agsubg(g, name,1); agbindrec(subg, "Agraphinfo_t", sizeof(Agraphinfo_t), true); //node custom data - GD_alg(subg) = NEW(gdata); + GD_alg(subg) = gv_alloc(sizeof(gdata)); dfs(g, n, subg, marks); nodeInduce(subg); } @@ -124,7 +124,7 @@ graph_t **findCComp(graph_t * g, int *cnt, int *pinned) if (pinned) *pinned = pinflag; /* freed in layout */ - comps = cp = N_NEW(c_cnt + 1, graph_t *); + comps = cp = gv_calloc(c_cnt + 1, sizeof(graph_t*)); for (subg = agfstsubg(g); subg; subg = agnxtsubg(subg)) { *cp++ = subg; c_cnt--;