]> granicus.if.org Git - graphviz/commitdiff
neatogen OverlapSmoother_new: use cgraph wrappers for allocation
authorMatthew Fernandez <matthew.fernandez@gmail.com>
Fri, 7 Oct 2022 02:37:07 +0000 (19:37 -0700)
committerMatthew Fernandez <matthew.fernandez@gmail.com>
Tue, 11 Oct 2022 00:40:54 +0000 (17:40 -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/neatogen/overlap.c

index 015449874c19fc70917f9e6ae00c5ec904e165bd..7d6b3fead560bc14b313abbfabf838e7f7d9f351 100644 (file)
@@ -366,14 +366,13 @@ OverlapSmoother OverlapSmoother_new(SparseMatrix A, int m,
                                    double *max_overlap, double *min_overlap,
                                    int edge_labeling_scheme, int n_constr_nodes, int *constr_nodes, SparseMatrix A_constr, int shrink
                                    ){
-  OverlapSmoother sm;
   int i, j, k, *iw, *jw, jdiag;
   SparseMatrix B;
-  double *lambda, *d, *w, diag_d, diag_w, dist;
+  double *d, *w, diag_d, diag_w, dist;
 
   assert((!A) || SparseMatrix_is_symmetric(A, false));
 
-  sm = GNEW(struct OverlapSmoother_struct);
+  OverlapSmoother sm = gv_alloc(sizeof(struct OverlapSmoother_struct));
   sm->scheme = SM_SCHEME_NORMAL;
   if (constr_nodes && n_constr_nodes > 0 && edge_labeling_scheme != ELSCHEME_NONE){
     sm->scheme = SM_SCHEME_NORMAL_ELABEL;
@@ -386,7 +385,7 @@ OverlapSmoother OverlapSmoother_new(SparseMatrix A, int m,
   sm->tol_cg = 0.01;
   sm->maxit_cg = sqrt((double) A->m);
 
-  lambda = sm->lambda = N_GNEW(m,double);
+  double *lambda = sm->lambda = gv_calloc(m, sizeof(double));
   for (i = 0; i < m; i++) sm->lambda[i] = lambda0;
   
   B= call_tri(m, x);