Skip to content

Commit f9011e1

Browse files
navyansh007kgryte
andauthored
bench: replace stack allocation with dynamic allocation
PR-URL: stdlib-js#7317 Ref: stdlib-js#7224 Ref: stdlib-js#369 Co-authored-by: Athan Reines <[email protected]> Reviewed-by: Athan Reines <[email protected]>
1 parent 0db0108 commit f9011e1

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

lib/node_modules/@stdlib/math/strided/special/dfloor/benchmark/c/benchmark.length.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,11 +114,13 @@ float rand_uniformf( float a, float b ) {
114114
*/
115115
static double benchmark( int iterations, int len ) {
116116
double elapsed;
117-
double x[ len ];
118-
double y[ len ];
117+
double *x;
118+
double *y;
119119
double t;
120120
int i;
121121

122+
x = (double *) malloc( len * sizeof( double ) );
123+
y = (double *) malloc( len * sizeof( double ) );
122124
for ( i = 0; i < len; i++ ) {
123125
x[ i ] = rand_uniform( -10.0, 10.0 );
124126
y[ i ] = 0.0;
@@ -136,6 +138,8 @@ static double benchmark( int iterations, int len ) {
136138
if ( y[ 0 ] != y[ 0 ] ) {
137139
printf( "should not return NaN\n" );
138140
}
141+
free( x );
142+
free( y );
139143
return elapsed;
140144
}
141145

0 commit comments

Comments
 (0)