Skip to content

Commit 69589e5

Browse files
bench: refactor to use dynamic memory allocation in blas/ext/base/slinspace
PR-URL: #10768 Ref: #8643 Reviewed-by: Philipp Burckhardt <[email protected]>
1 parent c8299c8 commit 69589e5

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

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

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

104+
x = (float *) malloc( len * sizeof( float ) );
104105
for ( i = 0; i < len; i++ ) {
105106
x[ i ] = ( rand_float()*200.0f ) - 100.0f;
106107
}
@@ -116,6 +117,7 @@ static double benchmark1( int iterations, int len ) {
116117
if ( x[ 0 ] != x[ 0 ] ) {
117118
printf( "should not return NaN\n" );
118119
}
120+
free( x );
119121
return elapsed;
120122
}
121123

@@ -128,10 +130,11 @@ static double benchmark1( int iterations, int len ) {
128130
*/
129131
static double benchmark2( int iterations, int len ) {
130132
double elapsed;
131-
float x[ len ];
133+
float *x;
132134
double t;
133135
int i;
134136

137+
x = (float *) malloc( len * sizeof( float ) );
135138
for ( i = 0; i < len; i++ ) {
136139
x[ i ] = ( rand_float()*200.0f ) - 100.0f;
137140
}
@@ -147,6 +150,7 @@ static double benchmark2( int iterations, int len ) {
147150
if ( x[ 0 ] != x[ 0 ] ) {
148151
printf( "should not return NaN\n" );
149152
}
153+
free( x );
150154
return elapsed;
151155
}
152156

0 commit comments

Comments
 (0)