From: Matthew Fernandez Date: Thu, 15 Sep 2022 00:53:49 +0000 (-0700) Subject: sparse SparseMatrix_realloc: use cgraph wrappers for allocation X-Git-Tag: 6.0.2~35^2~22 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=1edcb8c1104c3e4206b6972751d5bdfef789c746;p=graphviz 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. --- 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;