From: Matthew Fernandez Date: Thu, 15 Sep 2022 00:51:02 +0000 (-0700) Subject: sparse SparseMatrix_init: use cgraph wrappers for allocation X-Git-Tag: 6.0.2~35^2~24 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=3ad1e14666e83aaac15f46fc9f09d3d22bbc6151;p=graphviz sparse SparseMatrix_init: 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 d1dfcec38..7a90658b5 100644 --- a/lib/sparse/SparseMatrix.c +++ b/lib/sparse/SparseMatrix.c @@ -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;