4646 vector-valued or matrix-valued.
4747*/
4848
49+ #include "utils/tracked_alloc.h"
4950#include "utils/utils.h"
5051
5152static void refresh_param_values (left_matmul_expr * lnode )
@@ -148,7 +149,7 @@ static void wsum_hess_init_impl(expr *node)
148149 /* work for computing A^T w*/
149150 int n_blocks = ((left_matmul_expr * ) node )-> n_blocks ;
150151 int dim = ((left_matmul_expr * ) node )-> AT -> m * n_blocks ;
151- node -> work -> dwork = (double * ) malloc (dim * sizeof (double ));
152+ node -> work -> dwork = (double * ) SP_MALLOC (dim * sizeof (double ));
152153}
153154
154155static void eval_wsum_hess (expr * node , const double * w )
@@ -218,7 +219,7 @@ expr *new_left_matmul(expr *param_node, expr *u, const CSR_Matrix *A)
218219
219220 /* Allocate the type-specific struct */
220221 left_matmul_expr * lnode =
221- (left_matmul_expr * ) calloc (1 , sizeof (left_matmul_expr ));
222+ (left_matmul_expr * ) SP_CALLOC (1 , sizeof (left_matmul_expr ));
222223 expr * node = & lnode -> base ;
223224 init_expr (node , d1 , d2 , u -> n_vars , forward , jacobian_init_impl , eval_jacobian ,
224225 is_affine , wsum_hess_init_impl , eval_wsum_hess , free_type_data );
@@ -229,8 +230,8 @@ expr *new_left_matmul(expr *param_node, expr *u, const CSR_Matrix *A)
229230 (requiring size node->n_vars) and for transposing A (requiring size A->n).
230231 csc_to_csr_work is used for converting J_CSC to CSR (requiring
231232 node->size) */
232- node -> work -> iwork = (int * ) malloc (MAX (A -> n , node -> n_vars ) * sizeof (int ));
233- lnode -> csc_to_csr_work = (int * ) malloc (node -> size * sizeof (int ));
233+ node -> work -> iwork = (int * ) SP_MALLOC (MAX (A -> n , node -> n_vars ) * sizeof (int ));
234+ lnode -> csc_to_csr_work = (int * ) SP_MALLOC (node -> size * sizeof (int ));
234235 lnode -> n_blocks = n_blocks ;
235236
236237 /* store A and AT */
@@ -272,15 +273,15 @@ expr *new_left_matmul_dense(expr *param_node, expr *u, int m, int n,
272273 }
273274
274275 left_matmul_expr * lnode =
275- (left_matmul_expr * ) calloc (1 , sizeof (left_matmul_expr ));
276+ (left_matmul_expr * ) SP_CALLOC (1 , sizeof (left_matmul_expr ));
276277 expr * node = & lnode -> base ;
277278 init_expr (node , d1 , d2 , u -> n_vars , forward , jacobian_init_impl , eval_jacobian ,
278279 is_affine , wsum_hess_init_impl , eval_wsum_hess , free_type_data );
279280 node -> left = u ;
280281 expr_retain (u );
281282
282- node -> work -> iwork = (int * ) malloc (MAX (n , node -> n_vars ) * sizeof (int ));
283- lnode -> csc_to_csr_work = (int * ) malloc (node -> size * sizeof (int ));
283+ node -> work -> iwork = (int * ) SP_MALLOC (MAX (n , node -> n_vars ) * sizeof (int ));
284+ lnode -> csc_to_csr_work = (int * ) SP_MALLOC (node -> size * sizeof (int ));
284285 lnode -> n_blocks = n_blocks ;
285286
286287 lnode -> A = new_dense_matrix (m , n , data );
0 commit comments