]> granicus.if.org Git - graphviz/commitdiff
sfdpgen spring_electrical_spring_embedding: use cgraph wrappers for allocation
authorMatthew Fernandez <matthew.fernandez@gmail.com>
Sat, 10 Sep 2022 03:41:21 +0000 (20:41 -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/spring_electrical.c

index 762408dfd55c5e8a989d3d377945ba730ebb85bd..b9a3881087845f4f4ee90a3f879f90d5d78c00d5 100644 (file)
@@ -1406,9 +1406,9 @@ void spring_electrical_spring_embedding(int dim, SparseMatrix A0, SparseMatrix D
 
   if (n >= ctrl->quadtree_size) {
     USE_QT = TRUE;
-    center = MALLOC(sizeof(double)*nsupermax*dim);
-    supernode_wgts = MALLOC(sizeof(double)*nsupermax);
-    distances = MALLOC(sizeof(double)*nsupermax);
+    center = gv_calloc(nsupermax * dim, sizeof(double));
+    supernode_wgts = gv_calloc(nsupermax, sizeof(double));
+    distances = gv_calloc(nsupermax, sizeof(double));
   }
   *flag = 0;
   if (m != n) {
@@ -1447,8 +1447,8 @@ void spring_electrical_spring_embedding(int dim, SparseMatrix A0, SparseMatrix D
   }
 #endif
 
-  f = MALLOC(sizeof(double)*dim);
-  xold = MALLOC(sizeof(double)*dim*n);
+  f = gv_calloc(dim, sizeof(double));
+  xold = gv_calloc(dim * n, sizeof(double));
   do {
     iter++;
     memcpy(xold, x, sizeof(double)*dim*n);