]> granicus.if.org Git - graphviz/commitdiff
sparse SparseMatrix_init: use cgraph wrappers for allocation
authorMatthew Fernandez <matthew.fernandez@gmail.com>
Thu, 15 Sep 2022 00:51:02 +0000 (17:51 -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 d1dfcec38c29f97e2cb85a9a45dd6b2aab38cbc7..7a90658b562c16ad41d39a37350cc68d540d74a3 100644 (file)
@@ -291,10 +291,7 @@ int SparseMatrix_is_symmetric(SparseMatrix A, bool test_pattern_symmetry_only){
 }
 
 static SparseMatrix SparseMatrix_init(int m, int n, int type, size_t sz, int format){
-  SparseMatrix A;
-
-
-  A = MALLOC(sizeof(struct SparseMatrix_struct));
+  SparseMatrix A = gv_alloc(sizeof(struct SparseMatrix_struct));
   A->m = m;
   A->n = n;
   A->nz = 0;
@@ -308,7 +305,7 @@ static SparseMatrix SparseMatrix_init(int m, int n, int type, size_t sz, int for
   case FORMAT_CSC:
   case FORMAT_CSR:
   default:
-    A->ia = MALLOC(sizeof(int)*((size_t)(m+1)));
+    A->ia = gv_calloc((size_t)(m + 1), sizeof(int));
   }
   A->ja = NULL;
   A->a = NULL;