]> granicus.if.org Git - graphviz/commitdiff
sfdpgen Multilevel_coarsen_internal: use cgraph wrappers for allocation
authorMatthew Fernandez <matthew.fernandez@gmail.com>
Sat, 10 Sep 2022 03:14:38 +0000 (20:14 -0700)
committerMatthew Fernandez <matthew.fernandez@gmail.com>
Sun, 11 Sep 2022 23:56:02 +0000 (16:56 -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/sfdpgen/Multilevel.c

index 7de0060d0ba5f5f6d900d1f165ba02c080d9c89a..acbda76899c08712e2832b28fdea606ab5b6da46 100644 (file)
@@ -10,7 +10,6 @@
 
 #include <sfdpgen/Multilevel.h>
 #include <sfdpgen/PriorityQueue.h>
-#include <common/memory.h>
 #include <assert.h>
 #include <cgraph/alloc.h>
 #include <common/arith.h>
@@ -889,9 +888,9 @@ static void Multilevel_coarsen_internal(SparseMatrix A, SparseMatrix *cA, Sparse
 #endif
       goto RETURN;
     }
-    irn = N_GNEW(n,int);
-    jcn = N_GNEW(n,int);
-    val = N_GNEW(n,double);
+    irn = gv_calloc(n, sizeof(int));
+    jcn = gv_calloc(n, sizeof(int));
+    val = gv_calloc(n, sizeof(double));
     nzc = 0; 
     for (i = 0; i < ncluster; i++){
       for (j = clusterp[i]; j < clusterp[i+1]; j++){
@@ -942,9 +941,9 @@ static void Multilevel_coarsen_internal(SparseMatrix A, SparseMatrix *cA, Sparse
 #endif
       goto RETURN;
     }
-    irn = N_GNEW(n,int);
-    jcn = N_GNEW(n,int);
-    val = N_GNEW(n,double);
+    irn = gv_calloc(n, sizeof(int));
+    jcn = gv_calloc(n, sizeof(int));
+    val = gv_calloc(n, sizeof(double));
     nzc = 0; nc = 0;
     for (i = 0; i < n; i++){
       if (matching[i] >= 0){
@@ -1004,9 +1003,9 @@ static void Multilevel_coarsen_internal(SparseMatrix A, SparseMatrix *cA, Sparse
 #endif
       goto RETURN;
     }
-    irn = N_GNEW(nzc,int);
-    jcn = N_GNEW(nzc,int);
-    val = N_GNEW(nzc,double);
+    irn = gv_calloc(nzc, sizeof(int));
+    jcn = gv_calloc(nzc, sizeof(int));
+    val = gv_calloc(nzc, sizeof(double));
     nzc = 0; 
     for (i = 0; i < n; i++){
       if (vset[i] == MAX_IND_VTX_SET_F){