]> granicus.if.org Git - graphviz/commitdiff
neatogen generateNonoverlapConstraints: use cgraph wrappers for allocation
authorMatthew Fernandez <matthew.fernandez@gmail.com>
Fri, 18 Nov 2022 01:14:41 +0000 (17:14 -0800)
committerMatthew Fernandez <matthew.fernandez@gmail.com>
Sat, 3 Dec 2022 21:23:48 +0000 (13:23 -0800)
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/neatogen/quad_prog_vpsc.c

index a229a2bcb0d250a139a945e8c6750c920ef4d87b..31e34b4b6cbcba9fc43c9f9af6faff765866735f 100644 (file)
@@ -358,7 +358,7 @@ void generateNonoverlapConstraints(CMajEnvVPSC * e,
     Constraint **csol, **csolptr;
     int i, j, mol = 0;
     int n = e->nv + e->nldv;
-    boxf* bb = N_GNEW (n, boxf);
+    boxf* bb = gv_calloc(n, sizeof(boxf));
     bool genclusters = opt->clusters->nclusters > 0;
     if (genclusters) {
        /* n is the number of real variables, not dummy cluster vars */
@@ -385,12 +385,13 @@ void generateNonoverlapConstraints(CMajEnvVPSC * e,
            opt->gap.y / 2.0;
     }
     if (genclusters) {
-       Constraint ***cscl = N_GNEW(opt->clusters->nclusters + 1, Constraint**);
-       int* cm = N_GNEW(opt->clusters->nclusters + 1, int);
+       Constraint ***cscl = gv_calloc(opt->clusters->nclusters + 1,
+                                      sizeof(Constraint**));
+       int* cm = gv_calloc(opt->clusters->nclusters + 1, sizeof(int));
        for (i = 0; i < opt->clusters->nclusters; i++) {
            int cn = opt->clusters->clustersizes[i];
-           Variable** cvs = N_GNEW(cn + 2, Variable*);
-           boxf* cbb = N_GNEW(cn + 2, boxf);
+           Variable** cvs = gv_calloc(cn + 2, sizeof(Variable*));
+           boxf* cbb = gv_calloc(cn + 2, sizeof(boxf));
            /* compute cluster bounding bb */
            boxf container;
            container.LL.x = container.LL.y = DBL_MAX;
@@ -424,8 +425,8 @@ void generateNonoverlapConstraints(CMajEnvVPSC * e,
        /* generate top level constraints */
        {
            int cn = opt->clusters->ntoplevel + opt->clusters->nclusters;
-           Variable** cvs = N_GNEW(cn,Variable*);
-           boxf* cbb = N_GNEW(cn, boxf);
+           Variable** cvs = gv_calloc(cn, sizeof(Variable*));
+           boxf* cbb = gv_calloc(cn, sizeof(boxf));
            for (i = 0; i < opt->clusters->ntoplevel; i++) {
                int iv = opt->clusters->toplevel[i];
                cvs[i] = e->vs[iv];