From 31e7d68cf540fc144131d5a58bee5ecd4e1de43c Mon Sep 17 00:00:00 2001 From: Matthew Fernandez Date: Tue, 20 Sep 2022 19:15:13 -0700 Subject: [PATCH] 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. --- lib/pack/pack.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) 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); -- 2.40.0