Skip to content

Commit 6ec2cb3

Browse files
bench: refactor to use dynamic memory allocation in blas/ext/base/snansumors
PR-URL: #8761 Ref: #8643 Reviewed-by: Athan Reines <kgryte@gmail.com>
1 parent 1491c49 commit 6ec2cb3

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

lib/node_modules/@stdlib/blas/ext/base/snansumors/benchmark/c/benchmark.length.c

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

104+
x = (float *) malloc( len * sizeof( float ) );
104105
for ( i = 0; i < len; i++ ) {
105106
if ( rand_float() < 0.2f ) {
106107
x[ i ] = 0.0f / 0.0f; // NaN
@@ -122,6 +123,7 @@ static double benchmark1( int iterations, int len ) {
122123
if ( v != v ) {
123124
printf( "should not return NaN\n" );
124125
}
126+
free( x );
125127
return elapsed;
126128
}
127129

@@ -134,11 +136,12 @@ static double benchmark1( int iterations, int len ) {
134136
*/
135137
static double benchmark2( int iterations, int len ) {
136138
double elapsed;
137-
float x[ len ];
139+
float *x;
138140
float v;
139141
double t;
140142
int i;
141143

144+
x = (float *) malloc( len * sizeof( float ) );
142145
for ( i = 0; i < len; i++ ) {
143146
if ( rand_float() < 0.2f ) {
144147
x[ i ] = 0.0f / 0.0f; // NaN
@@ -160,6 +163,7 @@ static double benchmark2( int iterations, int len ) {
160163
if ( v != v ) {
161164
printf( "should not return NaN\n" );
162165
}
166+
free( x );
163167
return elapsed;
164168
}
165169

0 commit comments

Comments
 (0)