@@ -554,6 +554,7 @@ void frolladaptivemaxExact(const double *x, uint64_t nx, ans_t *ans, const int *
554554 }
555555 }
556556 }
557+ free (isnan );
557558 }
558559}
559560
@@ -581,7 +582,6 @@ void frolladaptiveminExact(const double *x, uint64_t nx, ans_t *ans, const int *
581582 bool * isnan = malloc (sizeof (* isnan ) * nx ); // isnan lookup - we use it to reduce ISNAN calls in nested loop
582583 if (!isnan ) { // # nocov start
583584 ansSetMsg (ans , 3 , "%s: Unable to allocate memory for isnan" , __func__ ); // raise error
584- free (isnan );
585585 return ;
586586 } // # nocov end
587587 bool truehasnf = hasnf > 0 ;
@@ -633,6 +633,7 @@ void frolladaptiveminExact(const double *x, uint64_t nx, ans_t *ans, const int *
633633 }
634634 }
635635 }
636+ free (isnan );
636637 }
637638}
638639
@@ -647,7 +648,6 @@ void frolladaptiveprodFast(const double *x, uint64_t nx, ans_t *ans, const int *
647648 double * cs = malloc (sizeof (* cs ) * nx );
648649 if (!cs ) { // # nocov start
649650 ansSetMsg (ans , 3 , "%s: Unable to allocate memory for cumprod" , __func__ ); // raise error
650- free (cs );
651651 return ;
652652 } // # nocov end
653653 if (!truehasnf ) {
@@ -679,19 +679,19 @@ void frolladaptiveprodFast(const double *x, uint64_t nx, ans_t *ans, const int *
679679 uint64_t * cn = malloc (sizeof (* cn ) * nx ); // cumulative NA counter, used the same way as cumprod, same as uint64_t cn[nx] but no segfault
680680 if (!cn ) { // # nocov start
681681 ansSetMsg (ans , 3 , "%s: Unable to allocate memory for cum NA counter" , __func__ ); // raise error
682- free (cs ); free ( cn );
682+ free (cs );
683683 return ;
684684 } // # nocov end
685685 uint64_t * cpinf = malloc (sizeof (* cpinf ) * nx );
686686 if (!cpinf ) { // # nocov start
687687 ansSetMsg (ans , 3 , "%s: Unable to allocate memory for cum Inf counter" , __func__ ); // raise error
688- free (cs ); free (cn ); free ( cpinf );
688+ free (cs ); free (cn );
689689 return ;
690690 } // # nocov end
691691 uint64_t * cninf = malloc (sizeof (* cninf ) * nx );
692692 if (!cninf ) { // # nocov start
693693 ansSetMsg (ans , 3 , "%s: Unable to allocate memory for cum -Inf counter" , __func__ ); // raise error
694- free (cs ); free (cn ); free (cpinf ); free ( cninf );
694+ free (cs ); free (cn ); free (cpinf );
695695 return ;
696696 } // # nocov end
697697 for (uint64_t i = 0 ; i < nx ; i ++ ) { // loop over observations to calculate cumprod and cum NA counter
0 commit comments