]> granicus.if.org Git - graphviz/commitdiff
neatogen initCMajVPSC: 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:24 +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 21e48fde82acd86bf524f3acb5b91795b0c6a0d0..a229a2bcb0d250a139a945e8c6750c920ef4d87b 100644 (file)
@@ -22,6 +22,7 @@
  * Tim Dwyer, 2006
  **********************************************************/
 
+#include <cgraph/alloc.h>
 #include <neatogen/digcola.h>
 #include <stdbool.h>
 #ifdef IPSEPCOLA
@@ -188,7 +189,7 @@ CMajEnvVPSC *initCMajVPSC(int n, float *packedMat, vtx_data * graph,
     int i, j;
     /* nv is the number of real nodes */
     int nConCs;
-    CMajEnvVPSC *e = GNEW(CMajEnvVPSC);
+    CMajEnvVPSC *e = gv_alloc(sizeof(CMajEnvVPSC));
     e->A = NULL;
     e->packedMat = packedMat;
     /* if we have clusters then we'll need two constraints for each var in
@@ -198,7 +199,7 @@ CMajEnvVPSC *initCMajVPSC(int n, float *packedMat, vtx_data * graph,
     e->ndv = 0;
 
     e->gcs = NULL;
-    e->vs = N_GNEW(n, Variable *);
+    e->vs = gv_calloc(n, sizeof(Variable*));
     for (i = 0; i < n; i++) {
        e->vs[i] = newVariable(i, 1.0, 1.0);
     }
@@ -239,7 +240,7 @@ CMajEnvVPSC *initCMajVPSC(int n, float *packedMat, vtx_data * graph,
            get_num_digcola_constraints(levels, e->ndv + 1) + e->ndv - 1;
        e->gcs = newConstraints(e->gm);
        e->gm = 0;
-       e->vs = N_GNEW(n + e->ndv, Variable *);
+       e->vs = gv_calloc(n + e->ndv, sizeof(Variable*));
        for (i = 0; i < n; i++) {
            e->vs[i] = vs[i];
        }
@@ -303,9 +304,9 @@ CMajEnvVPSC *initCMajVPSC(int n, float *packedMat, vtx_data * graph,
        e->A = unpackMatrix(packedMat, n);
     }
 
-    e->fArray1 = N_GNEW(n, float);
-    e->fArray2 = N_GNEW(n, float);
-    e->fArray3 = N_GNEW(n, float);
+    e->fArray1 = gv_calloc(n, sizeof(float));
+    e->fArray2 = gv_calloc(n, sizeof(float));
+    e->fArray3 = gv_calloc(n, sizeof(float));
     if (Verbose)
        fprintf(stderr,
                "  initCMajVPSC done: %d global constraints generated.\n",