From: Matthew Fernandez Date: Thu, 15 Sep 2022 01:09:49 +0000 (-0700) Subject: sparse SparseMatrix_get_augmented: use cgraph wrappers for allocation X-Git-Tag: 6.0.2~35^2~10 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=5deeb5f146a14aeea1b74ca3595703ae25e1a2f3;p=graphviz sparse SparseMatrix_get_augmented: 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 5f1a85744..321958796 100644 --- a/lib/sparse/SparseMatrix.c +++ b/lib/sparse/SparseMatrix.c @@ -2113,13 +2113,13 @@ SparseMatrix SparseMatrix_get_augmented(SparseMatrix A){ SparseMatrix B = NULL; if (!A) return NULL; if (nz > 0){ - irn = MALLOC(sizeof(int)*((size_t)nz)*2); - jcn = MALLOC(sizeof(int)*((size_t)nz)*2); + irn = gv_calloc((size_t)nz * 2, sizeof(int)); + jcn = gv_calloc((size_t)nz * 2, sizeof(int)); } if (A->a){ assert(A->size != 0 && nz > 0); - val = MALLOC(A->size*2*((size_t)nz)); + val = gv_calloc(2 * (size_t)nz, A->size); memcpy(val, A->a, A->size*((size_t)nz)); memcpy(((char*) val) + ((size_t)nz)*A->size, A->a, A->size*((size_t)nz)); }