From: Matthew Fernandez Date: Thu, 15 Sep 2022 00:53:20 +0000 (-0700) Subject: sparse SparseMatrix_alloc: use cgraph wrappers for allocation X-Git-Tag: 6.0.2~35^2~23 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=f19366937d1e35737a27911fe998dbc82e19ddda;p=graphviz sparse SparseMatrix_alloc: 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 7a90658b5..c924bd540 100644 --- a/lib/sparse/SparseMatrix.c +++ b/lib/sparse/SparseMatrix.c @@ -325,16 +325,16 @@ static SparseMatrix SparseMatrix_alloc(SparseMatrix A, int nz){ A->a = NULL; switch (format){ case FORMAT_COORD: - A->ia = MALLOC(sizeof(int)*nz_t); - A->ja = MALLOC(sizeof(int)*nz_t); - A->a = MALLOC(A->size*nz_t); + A->ia = gv_calloc(nz_t, sizeof(int)); + A->ja = gv_calloc(nz_t, sizeof(int)); + A->a = gv_calloc(nz_t, A->size); break; case FORMAT_CSR: case FORMAT_CSC: default: - A->ja = MALLOC(sizeof(int)*nz_t); + A->ja = gv_calloc(nz_t, sizeof(int)); if (A->size > 0 && nz_t > 0) { - A->a = MALLOC(A->size*nz_t); + A->a = gv_calloc(nz_t, A->size); } break; }