Skip to content

Commit fd0eac6

Browse files
authored
bench: refactor to use dynamic memory allocation in strided/base/smap
PR-URL: #9353 Ref: #8643 Reviewed-by: Athan Reines <kgryte@gmail.com>
1 parent cb25fd3 commit fd0eac6

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

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

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

114+
x = (float *)malloc( len * sizeof( float ) );
115+
y = (float *)malloc( len * sizeof( float ) );
114116
for ( i = 0; i < len; i++ ) {
115117
x[ i ] = ( rand_float()*200.0f ) - 100.0f;
116118
y[ i ] = 0.0f;
@@ -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)