Skip to content

Commit 7f95ab0

Browse files
authored
bench: refactor to use dynamic memory allocation in stats/base/snanvariance
PR-URL: #11640 Reviewed-by: Athan Reines <kgryte@gmail.com> Ref: #8643
1 parent 1bd2ab6 commit 7f95ab0

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

lib/node_modules/@stdlib/stats/base/snanvariance/benchmark/c/benchmark.length.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,11 +96,12 @@ static float rand_float( void ) {
9696
*/
9797
static double benchmark( int iterations, int len ) {
9898
double elapsed;
99-
float x[ len ];
99+
float *x;
100100
float v;
101101
double t;
102102
int i;
103103

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

0 commit comments

Comments
 (0)