Skip to content

Commit 8289a03

Browse files
bench: refactor to use dynamic memory allocation in math/strided/special/strunc
PR-URL: #9481 Ref: #8643 Ref: #369 Co-authored-by: Athan Reines <kgryte@gmail.com> Reviewed-by: Athan Reines <kgryte@gmail.com> Reviewed-by: Muhammad Haris <harriskhan047@outlook.com>
1 parent c6c2de6 commit 8289a03

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

lib/node_modules/@stdlib/math/strided/special/strunc/benchmark/c/benchmark.length.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,11 +114,13 @@ float rand_uniformf( float a, float b ) {
114114
*/
115115
static double benchmark( int iterations, int len ) {
116116
double elapsed;
117-
float x[ len ];
118-
float y[ len ];
117+
float *x;
118+
float *y;
119119
double t;
120120
int i;
121121

122+
x = (float *)malloc( len * sizeof( float ) );
123+
y = (float *)malloc( len * sizeof( float ) );
122124
for ( i = 0; i < len; i++ ) {
123125
x[ i ] = rand_uniformf( -10.0f, 10.0f );
124126
y[ i ] = 0.0f;
@@ -135,6 +137,8 @@ static double benchmark( int iterations, int len ) {
135137
if ( y[ 0 ] != y[ 0 ] ) {
136138
printf( "should not return NaN\n" );
137139
}
140+
free( x );
141+
free( y );
138142
return elapsed;
139143
}
140144

0 commit comments

Comments
 (0)