]> granicus.if.org Git - graphviz/commitdiff
sparse SparseMatrix_weakly_connected_compone…: use cgraph wrapper for allocation
authorMatthew Fernandez <matthew.fernandez@gmail.com>
Thu, 15 Sep 2022 00:58:56 +0000 (17:58 -0700)
committerMatthew Fernandez <matthew.fernandez@gmail.com>
Tue, 20 Sep 2022 14:36:59 +0000 (07:36 -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/sparse/SparseMatrix.c

index df5ae3be837739e31e077265de91835c7fbb97a9..cd984f1c739ad94305ff14b6c32e4245399d8440 100644 (file)
@@ -1840,7 +1840,7 @@ void SparseMatrix_weakly_connected_components(SparseMatrix A0, int *ncomp, int *
   if (!SparseMatrix_is_symmetric(A, true)){
     A = SparseMatrix_symmetrize(A, true);
   }
-  if (!(*comps_ptr)) *comps_ptr = MALLOC(sizeof(int)*((size_t)(m+1)));
+  if (!(*comps_ptr)) *comps_ptr = gv_calloc((size_t)(m + 1), sizeof(int));
 
   *ncomp = 0;
   (*comps_ptr)[0] = 0;