Skip to content

Commit 9df0e8d

Browse files
authored
bench: refactor to use dynamic memory allocation in blas/ext/base/dsumkbn2
PR-URL: #8909 Ref: #8643 Ref: #369 Reviewed-by: Athan Reines <[email protected]>
1 parent 58614e9 commit 9df0e8d

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

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

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

104+
x = (double *)malloc( len * sizeof( double ) );
104105
for ( i = 0; i < len; i++ ) {
105106
x[ i ] = ( rand_double() * 20000.0 ) - 10000.0;
106107
}
@@ -118,6 +119,7 @@ static double benchmark1( int iterations, int len ) {
118119
if ( v != v ) {
119120
printf( "should not return NaN\n" );
120121
}
122+
free( x );
121123
return elapsed;
122124
}
123125

@@ -130,11 +132,12 @@ static double benchmark1( int iterations, int len ) {
130132
*/
131133
static double benchmark2( int iterations, int len ) {
132134
double elapsed;
133-
double x[ len ];
135+
double *x;
134136
double v;
135137
double t;
136138
int i;
137139

140+
x = (double *)malloc( len * sizeof( double ) );
138141
for ( i = 0; i < len; i++ ) {
139142
x[ i ] = ( rand_double() * 20000.0 ) - 10000.0;
140143
}
@@ -152,6 +155,7 @@ static double benchmark2( int iterations, int len ) {
152155
if ( v != v ) {
153156
printf( "should not return NaN\n" );
154157
}
158+
free( x );
155159
return elapsed;
156160
}
157161

0 commit comments

Comments
 (0)