Skip to content

Commit 514b822

Browse files
authored
bench: refactor to use dynamic memory allocation in stats/strided/dstdev
PR-URL: #11595 Ref: #8643 Reviewed-by: Philipp Burckhardt <pburckhardt@outlook.com>
1 parent c7b8e82 commit 514b822

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,11 +96,12 @@ 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;
103103

104+
x = (double *) malloc( len * sizeof( double ) );
104105
for ( i = 0; i < len; i++ ) {
105106
x[ i ] = ( rand_double() * 20000.0 ) - 10000.0;
106107
}
@@ -117,6 +118,7 @@ static double benchmark( int iterations, int len ) {
117118
if ( v != v ) {
118119
printf( "should not return NaN\n" );
119120
}
121+
free( x );
120122
return elapsed;
121123
}
122124

0 commit comments

Comments
 (0)