Skip to content

Commit 4ef4f29

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

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

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

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

115+
x = (double complex *)malloc( len * sizeof( double complex ) );
116+
y = (double complex *)malloc( len * sizeof( double complex ) );
115117
for ( i = 0; i < len; i++ ) {
116118
x[ i ] = ( ( rand_double()*200.0 ) - 100.0 ) + ( ( rand_double()*200.0 ) - 100.0 )*I;
117119
y[ i ] = 0.0 + 0.0*I;
@@ -129,6 +131,8 @@ static double benchmark( int iterations, int len ) {
129131
if ( y[ i%len ] != y[ i%len ] ) {
130132
printf( "should not return NaN\n" );
131133
}
134+
free( x );
135+
free( y );
132136
return elapsed;
133137
}
134138

0 commit comments

Comments
 (0)