From 3b7df8cf64c47d8b079e19492d143619e666443b Mon Sep 17 00:00:00 2001 From: Matthew Fernandez Date: Wed, 14 Sep 2022 18:14:10 -0700 Subject: [PATCH] sparse SparseMatrix_distance_matrix: 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. --- lib/sparse/SparseMatrix.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/sparse/SparseMatrix.c b/lib/sparse/SparseMatrix.c index f86768741..922e30d3a 100644 --- a/lib/sparse/SparseMatrix.c +++ b/lib/sparse/SparseMatrix.c @@ -2385,7 +2385,7 @@ int SparseMatrix_distance_matrix(SparseMatrix D0, int weighted, double **dist0){ assert(m == n); - if (!(*dist0)) *dist0 = MALLOC(sizeof(double)*n*n); + if (!(*dist0)) *dist0 = gv_calloc(n * n, sizeof(double)); for (i = 0; i < n*n; i++) (*dist0)[i] = -1; if (!weighted){ @@ -2399,7 +2399,7 @@ int SparseMatrix_distance_matrix(SparseMatrix D0, int weighted, double **dist0){ } } } else { - list = MALLOC(sizeof(int)*n); + list = gv_calloc(n, sizeof(int)); for (k = 0; k < n; k++){ dist = &((*dist0)[k*n]); flag = Dijkstra(D, k, dist, &nlist, list, &dmax); -- 2.50.1