From: Matthew Fernandez Date: Wed, 21 Sep 2022 02:15:13 +0000 (-0700) Subject: pack polyRects: use cgraph wrappers for allocation X-Git-Tag: 6.0.2~31^2~11 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=31e7d68cf540fc144131d5a58bee5ecd4e1de43c;p=graphviz pack polyRects: 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/pack/pack.c b/lib/pack/pack.c index fc0c6a6e7..018650506 100644 --- a/lib/pack/pack.c +++ b/lib/pack/pack.c @@ -721,9 +721,6 @@ static point* polyRects(int ng, boxf* gs, pack_info * pinfo) { int stepSize; - ginfo *info; - ginfo **sinfo; - point *places; Dict_t *ps; int i; point center; @@ -737,21 +734,21 @@ polyRects(int ng, boxf* gs, pack_info * pinfo) /* generate polyomino cover for the rectangles */ center.x = center.y = 0; - info = N_NEW(ng, ginfo); + ginfo *info = gv_calloc(ng, sizeof(ginfo)); for (i = 0; i < ng; i++) { info[i].index = i; genBox(gs[i], info + i, stepSize, pinfo->margin, center, ""); } /* sort */ - sinfo = N_NEW(ng, ginfo *); + ginfo **sinfo = gv_calloc(ng, sizeof(ginfo*)); for (i = 0; i < ng; i++) { sinfo[i] = info + i; } qsort(sinfo, ng, sizeof(ginfo *), cmpf); ps = newPS(); - places = N_NEW(ng, point); + point *places = gv_calloc(ng, sizeof(point)); for (i = 0; i < ng; i++) placeGraph(i, sinfo[i], ps, places + sinfo[i]->index, stepSize, pinfo->margin, gs);