From: Matthew Fernandez Date: Thu, 15 Sep 2022 01:14:10 +0000 (-0700) Subject: sparse SparseMatrix_distance_matrix: use cgraph wrappers for allocation X-Git-Tag: 6.0.2~35^2~7 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=3b7df8cf64c47d8b079e19492d143619e666443b;p=graphviz 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. --- 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);