Skip to content

Commit 647a947

Browse files
bench: refactor to use dynamic memory allocation in strided/base/dmap
PR-URL: #11566 Ref: #8643 Reviewed-by: Philipp Burckhardt <pburckhardt@outlook.com>
1 parent fffff98 commit 647a947

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

lib/node_modules/@stdlib/strided/base/dmap/benchmark/c/benchmark.length.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,11 +106,13 @@ static double identity( const double x ) {
106106
*/
107107
static double benchmark( int iterations, int len ) {
108108
double elapsed;
109-
double x[ len ];
110-
double y[ len ];
109+
double *x;
110+
double *y;
111111
double t;
112112
int i;
113113

114+
x = (double *)malloc( len * sizeof( double ) );
115+
y = (double *)malloc( len * sizeof( double ) );
114116
for ( i = 0; i < len; i++ ) {
115117
x[ i ] = ( rand_double()*200.0 ) - 100.0;
116118
y[ i ] = 0.0;
@@ -128,6 +130,8 @@ static double benchmark( int iterations, int len ) {
128130
if ( y[ i%len ] != y[ i%len ] ) {
129131
printf( "should not return NaN\n" );
130132
}
133+
free( x );
134+
free( y );
131135
return elapsed;
132136
}
133137

0 commit comments

Comments
 (0)