Skip to content

Commit 05b2f70

Browse files
authored
bench: refactor to use dynamic memory allocation in math/strided/special/dabs
PR-URL: #11655 Ref: #8643 Reviewed-by: Philipp Burckhardt <pburckhardt@outlook.com>
1 parent cbfa3ed commit 05b2f70

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,11 +96,13 @@ static double rand_double( void ) {
9696
*/
9797
static double benchmark( int iterations, int len ) {
9898
double elapsed;
99-
double x[ len ];
100-
double y[ len ];
99+
double *x;
100+
double *y;
101101
double t;
102102
int i;
103103

104+
x = (double *) malloc( len * sizeof( double ) );
105+
y = (double *) malloc( len * sizeof( double ) );
104106
for ( i = 0; i < len; i++ ) {
105107
x[ i ] = ( rand_double()*200.0 ) - 100.0;
106108
y[ i ] = 0.0;
@@ -118,6 +120,8 @@ static double benchmark( int iterations, int len ) {
118120
if ( y[ 0 ] != y[ 0 ] ) {
119121
printf( "should not return NaN\n" );
120122
}
123+
free( x );
124+
free( y );
121125
return elapsed;
122126
}
123127

0 commit comments

Comments
 (0)