]> granicus.if.org Git - graphviz/commitdiff
pack polyRects: use cgraph wrappers for allocation
authorMatthew Fernandez <matthew.fernandez@gmail.com>
Wed, 21 Sep 2022 02:15:13 +0000 (19:15 -0700)
committerMatthew Fernandez <matthew.fernandez@gmail.com>
Thu, 22 Sep 2022 00:00:18 +0000 (17:00 -0700)
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

index fc0c6a6e76947360187809573bfe1c250506c3e8..0186505060a6b9d88bd904dc1dc950b0b1385865 100644 (file)
@@ -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);