Skip to content

Commit fffff98

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

1 file changed

Lines changed: 9 additions & 3 deletions

File tree

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

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -107,12 +107,15 @@ static double add( const double x, const double y ) {
107107
*/
108108
static double benchmark( int iterations, int len ) {
109109
double elapsed;
110-
double x[ len ];
111-
double y[ len ];
112-
double z[ len ];
110+
double *x;
111+
double *y;
112+
double *z;
113113
double t;
114114
int i;
115115

116+
x = (double *)malloc( len * sizeof( double ) );
117+
y = (double *)malloc( len * sizeof( double ) );
118+
z = (double *)malloc( len * sizeof( double ) );
116119
for ( i = 0; i < len; i++ ) {
117120
x[ i ] = ( rand_double()*200.0 ) - 100.0;
118121
y[ i ] = ( rand_double()*200.0 ) - 100.0;
@@ -130,6 +133,9 @@ static double benchmark( int iterations, int len ) {
130133
if ( z[ i%len ] != z[ i%len ] ) {
131134
printf( "should not return NaN\n" );
132135
}
136+
free( x );
137+
free( y );
138+
free( z );
133139
return elapsed;
134140
}
135141

0 commit comments

Comments
 (0)