Skip to content

Commit 39f9ad9

Browse files
authored
bench: refactor to use dynamic memory allocation in math/strided/special/dramp
PR-URL: #11664 Ref: #8643 Reviewed-by: Philipp Burckhardt <pburckhardt@outlook.com>
1 parent d440e3b commit 39f9ad9

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

lib/node_modules/@stdlib/math/strided/special/dramp/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;
@@ -135,6 +137,8 @@ static double benchmark( int iterations, int len ) {
135137
if ( y[ 0 ] != y[ 0 ] ) {
136138
printf( "should not return NaN\n" );
137139
}
140+
free( x );
141+
free( y );
138142
return elapsed;
139143
}
140144

0 commit comments

Comments
 (0)