From: Matthew Fernandez Date: Fri, 18 Nov 2022 01:14:41 +0000 (-0800) Subject: neatogen makeMatrix: use cgraph wrappers for allocation X-Git-Tag: 7.0.3~1^2~18 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=1ec31fe509d5608d50fb4732b1dfc97ff2ad2909;p=graphviz neatogen makeMatrix: 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/neatogen/adjust.c b/lib/neatogen/adjust.c index 0a6b96532..33f85e89e 100644 --- a/lib/neatogen/adjust.c +++ b/lib/neatogen/adjust.c @@ -667,9 +667,6 @@ SparseMatrix makeMatrix(Agraph_t* g, SparseMatrix *D) int nnodes; int nedges; int i, row; - int *I; - int *J; - double *val; double v; int type = MATRIX_TYPE_REAL; Agsym_t* symD = NULL; @@ -685,14 +682,14 @@ SparseMatrix makeMatrix(Agraph_t* g, SparseMatrix *D) for (n = agfstnode(g); n; n = agnxtnode(g, n)) ND_id(n) = i++; - I = N_GNEW(nedges, int); - J = N_GNEW(nedges, int); - val = N_GNEW(nedges, double); + int *I = gv_calloc(nedges, sizeof(int)); + int *J = gv_calloc(nedges, sizeof(int)); + double *val = gv_calloc(nedges, sizeof(double)); sym = agfindedgeattr(g, "weight"); if (D) { symD = agfindedgeattr(g, "len"); - valD = N_NEW(nedges, double); + valD = gv_calloc(nedges, sizeof(double)); } i = 0;