]> granicus.if.org Git - graphviz/commitdiff
sfdpgen multilevel_spring_electrical_embedd…: use cgraph wrappers for allocation
authorMatthew Fernandez <matthew.fernandez@gmail.com>
Sat, 10 Sep 2022 03:44:37 +0000 (20:44 -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 5d733ee590ee56f497266709bcb7c26708ee23bb..571a6494726b5cb6b024c1700719a9f5c6e49fc5 100644 (file)
@@ -18,7 +18,6 @@
 #include <sfdpgen/post_process.h>
 #include <neatogen/overlap.h>
 #include <common/types.h>
-#include <common/memory.h>
 #include <common/arith.h>
 #include <math.h>
 #include <common/globals.h>
@@ -1890,7 +1889,7 @@ static void multilevel_spring_electrical_embedding_core(int dim, SparseMatrix A0
       && n_edge_label_nodes > 0){
     SparseMatrix A2;
 
-    double *x2 = MALLOC(sizeof(double)*(A->m)*dim);
+    double *x2 = gv_calloc(A->m * dim, sizeof(double));
     A2 = shorting_edge_label_nodes(A, n_edge_label_nodes, edge_label_nodes);
     multilevel_spring_electrical_embedding(dim, A2, NULL, ctrl, NULL, x2, 0, NULL, flag);
 
@@ -1913,7 +1912,7 @@ static void multilevel_spring_electrical_embedding_core(int dim, SparseMatrix A0
   if (Multilevel_is_finest(grid)){
     xc = x;
   } else {
-    xc = MALLOC(sizeof(double)*grid->n*dim);
+    xc = gv_calloc(grid->n * dim, sizeof(double));
   }
 
   plg = power_law_graph(A);
@@ -1981,7 +1980,7 @@ static void multilevel_spring_electrical_embedding_core(int dim, SparseMatrix A0
     if (Multilevel_is_finest(grid)){
       xf = x;
     } else {
-      xf = MALLOC(sizeof(double)*grid->n*dim);
+      xf = gv_calloc(grid->n * dim, sizeof(double));
     }
     prolongate(dim, grid->A, P, grid->R, xc, xf, coarsen_scheme_used, (ctrl->K)*0.001);
     free(xc);