From 0a4819c1d3812a92b47b2452196b512dcde05665 Mon Sep 17 00:00:00 2001 From: Matthew Fernandez Date: Tue, 20 Sep 2022 19:14:36 -0700 Subject: [PATCH] pack arrayRects: 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 | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/lib/pack/pack.c b/lib/pack/pack.c index b1cc17756..fc0c6a6e7 100644 --- a/lib/pack/pack.c +++ b/lib/pack/pack.c @@ -608,12 +608,8 @@ arrayRects (int ng, boxf* gs, pack_info* pinfo) int nr = 0, nc; int r, c; ainfo *info; - ainfo *ip; - ainfo **sinfo; - double* widths; - double* heights; double v, wd, ht; - point* places = N_NEW(ng, point); + point *places = gv_calloc(ng, sizeof(point)); boxf bb; int sz, rowMajor; @@ -643,10 +639,10 @@ arrayRects (int ng, boxf* gs, pack_info* pinfo) } if (Verbose) fprintf (stderr, "array packing: %s %d rows %d columns\n", (rowMajor?"row major":"column major"), nr, nc); - widths = N_NEW(nc+1, double); - heights = N_NEW(nr+1, double); + double *widths = gv_calloc(nc + 1, sizeof(double)); + double *heights = gv_calloc(nr + 1, sizeof(double)); - ip = info = N_NEW(ng, ainfo); + ainfo *ip = info = gv_calloc(ng, sizeof(ainfo)); for (i = 0; i < ng; i++, ip++) { bb = gs[i]; ip->width = bb.UR.x - bb.LL.x + pinfo->margin; @@ -654,7 +650,7 @@ arrayRects (int ng, boxf* gs, pack_info* pinfo) ip->index = i; } - sinfo = N_NEW(ng, ainfo*); + ainfo **sinfo = gv_calloc(ng, sizeof(ainfo*)); for (i = 0; i < ng; i++) { sinfo[i] = info + i; } -- 2.40.0