From: Matthew Fernandez Date: Sat, 10 Sep 2022 03:40:52 +0000 (-0700) Subject: sfdpgen spring_maxent_embedding: use cgraph wrappers for allocation X-Git-Tag: 6.0.2~44^2~7 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=98d2badd0415bb2dd9883df9181fc997a4b9704e;p=graphviz sfdpgen spring_maxent_embedding: use cgraph wrappers for allocation 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. --- diff --git a/lib/sfdpgen/spring_electrical.c b/lib/sfdpgen/spring_electrical.c index 0a1688f4d..762408dfd 100644 --- a/lib/sfdpgen/spring_electrical.c +++ b/lib/sfdpgen/spring_electrical.c @@ -1200,9 +1200,9 @@ static void spring_maxent_embedding(int dim, SparseMatrix A0, SparseMatrix D, sp if (ctrl->tscheme != QUAD_TREE_NONE && 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; @@ -1259,8 +1259,8 @@ static void spring_maxent_embedding(int dim, SparseMatrix A0, SparseMatrix D, sp } #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);