Skip to content

Commit 1bd2ab6

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

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

lib/node_modules/@stdlib/stats/base/snanstdevyc/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
}
@@ -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)