From 318062cd4f7372ba954e9b29e14790f03ffe94d3 Mon Sep 17 00:00:00 2001 From: Matthew Fernandez Date: Wed, 15 Sep 2021 21:11:46 -0700 Subject: [PATCH] get_mq: abbreviate a malloc;memzero The calloc function can do this more concisely and efficiently. --- lib/sparse/mq.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/lib/sparse/mq.c b/lib/sparse/mq.c index 0826c7a98..2b57b5d49 100644 --- a/lib/sparse/mq.c +++ b/lib/sparse/mq.c @@ -83,9 +83,7 @@ static real get_mq(SparseMatrix A, int *assignment, int *ncluster0, real *mq_in0 assert(A->n == n); if (A->type == MATRIX_TYPE_REAL) a = (real*) A->a; - counts = MALLOC(sizeof(int)*n); - - for (i = 0; i < n; i++) counts[i] = 0; + counts = CALLOC(n, sizeof(int)); for (i = 0; i < n; i++){ assert(assignment[i] >= 0 && assignment[i] < n); -- 2.40.0