Skip to content

Commit e21e6df

Browse files
authored
bench: refactor to use dynamic memory allocation in stats/strided/dmean
PR-URL: #9773 Ref: #8643 Reviewed-by: Philipp Burckhardt <pburckhardt@outlook.com>
1 parent 5b02960 commit e21e6df

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

lib/node_modules/@stdlib/stats/strided/dmean/benchmark/c/benchmark.length.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,11 +96,11 @@ static double rand_double( void ) {
9696
*/
9797
static double benchmark( int iterations, int len ) {
9898
double elapsed;
99-
double x[ len ];
99+
double *x;
100100
double v;
101101
double t;
102102
int i;
103-
103+
x = (double *) malloc( len * sizeof( double ) );
104104
for ( i = 0; i < len; i++ ) {
105105
x[ i ] = ( rand_double() * 20000.0 ) - 10000.0;
106106
}
@@ -117,6 +117,7 @@ static double benchmark( int iterations, int len ) {
117117
if ( v != v ) {
118118
printf( "should not return NaN\n" );
119119
}
120+
free( x );
120121
return elapsed;
121122
}
122123

0 commit comments

Comments
 (0)