From 1edcb8c1104c3e4206b6972751d5bdfef789c746 Mon Sep 17 00:00:00 2001 From: Matthew Fernandez Date: Wed, 14 Sep 2022 17:53:49 -0700 Subject: [PATCH] sparse SparseMatrix_realloc: 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 | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/lib/sparse/SparseMatrix.c b/lib/sparse/SparseMatrix.c index c924bd540..77d371000 100644 --- a/lib/sparse/SparseMatrix.c +++ b/lib/sparse/SparseMatrix.c @@ -348,25 +348,25 @@ static SparseMatrix SparseMatrix_realloc(SparseMatrix A, int nz){ switch (format){ case FORMAT_COORD: - A->ia = REALLOC(A->ia, sizeof(int)*nz_t); - A->ja = REALLOC(A->ja, sizeof(int)*nz_t); + A->ia = gv_recalloc(A->ia, A->nzmax, nz_t, sizeof(int)); + A->ja = gv_recalloc(A->ja, A->nzmax, nz_t, sizeof(int)); if (A->size > 0) { if (A->a){ - A->a = REALLOC(A->a, A->size*nz_t); + A->a = gv_recalloc(A->a, A->nzmax, nz_t, A->size); } else { - A->a = MALLOC(A->size*nz_t); + A->a = gv_calloc(nz_t, A->size); } } break; case FORMAT_CSR: case FORMAT_CSC: default: - A->ja = REALLOC(A->ja, sizeof(int)*nz_t); + A->ja = gv_recalloc(A->ja, A->nzmax, nz_t, sizeof(int)); if (A->size > 0) { if (A->a){ - A->a = REALLOC(A->a, A->size*nz_t); + A->a = gv_recalloc(A->a, A->nzmax, nz_t, A->size); } else { - A->a = MALLOC(A->size*nz_t); + A->a = gv_calloc(nz_t, A->size); } } break; -- 2.50.1