1717 */
1818#include "atoms/affine.h"
1919#include "subexpr.h"
20+ #include "utils/tracked_alloc.h"
2021#include <assert.h>
2122#include <stdio.h>
2223#include <stdlib.h>
2829 * Returns true if duplicates exist, false otherwise. */
2930static bool check_for_duplicates (const int * indices , int n_idxs , int max_idx )
3031{
31- bool * seen = (bool * ) calloc (max_idx , sizeof (bool ));
32+ bool * seen = (bool * ) SP_CALLOC (max_idx , sizeof (bool ));
3233 bool has_dup = false;
3334 for (int i = 0 ; i < n_idxs && !has_dup ; i ++ )
3435 {
@@ -104,7 +105,7 @@ static void wsum_hess_init_impl(expr *node)
104105 wsum_hess_init (x );
105106
106107 /* for setting weight vector to evaluate hessian of child */
107- node -> work -> dwork = (double * ) calloc (x -> size , sizeof (double ));
108+ node -> work -> dwork = (double * ) SP_CALLOC (x -> size , sizeof (double ));
108109
109110 /* in the implementation of eval_wsum_hess we evaluate the
110111 child's hessian with a weight vector that has w[i] = 0
@@ -163,7 +164,7 @@ expr *new_index(expr *child, int d1, int d2, const int *indices, int n_idxs)
163164{
164165 assert (d1 * d2 == n_idxs );
165166 /* allocate type-specific struct */
166- index_expr * idx = (index_expr * ) calloc (1 , sizeof (index_expr ));
167+ index_expr * idx = (index_expr * ) SP_CALLOC (1 , sizeof (index_expr ));
167168 expr * node = & idx -> base ;
168169
169170 init_expr (node , d1 , d2 , child -> n_vars , forward , jacobian_init_impl ,
@@ -174,7 +175,7 @@ expr *new_index(expr *child, int d1, int d2, const int *indices, int n_idxs)
174175 expr_retain (child );
175176
176177 /* copy indices */
177- idx -> indices = (int * ) malloc (n_idxs * sizeof (int ));
178+ idx -> indices = (int * ) SP_MALLOC (n_idxs * sizeof (int ));
178179 memcpy (idx -> indices , indices , n_idxs * sizeof (int ));
179180 idx -> n_idxs = n_idxs ;
180181
0 commit comments