From f19366937d1e35737a27911fe998dbc82e19ddda Mon Sep 17 00:00:00 2001 From: Matthew Fernandez Date: Wed, 14 Sep 2022 17:53:20 -0700 Subject: [PATCH] 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. --- lib/sparse/SparseMatrix.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) 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; } -- 2.50.1