From e1df64f2f523a25de20a93e50f0eb42d926fe4a7 Mon Sep 17 00:00:00 2001 From: thzthix Date: Sun, 21 Dec 2025 02:50:39 +0900 Subject: [PATCH] refactor: convert static to dynamic allocation in benchmark1 and benchmark2 Signed-off-by: thzthix --- .../base/drrss/benchmark/c/benchmark.length.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/ext/base/drrss/benchmark/c/benchmark.length.c b/lib/node_modules/@stdlib/blas/ext/base/drrss/benchmark/c/benchmark.length.c index 3ee7ff290b56..d1277a6363b5 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/drrss/benchmark/c/benchmark.length.c +++ b/lib/node_modules/@stdlib/blas/ext/base/drrss/benchmark/c/benchmark.length.c @@ -96,12 +96,14 @@ static double rand_double( void ) { */ static double benchmark1( int iterations, int len ) { double elapsed; - double x[ len ]; - double y[ len ]; + double *x; + double *y; double v; double t; int i; + x = (double *) malloc( len * sizeof( double ) ); + y = (double *) malloc( len * sizeof( double ) ); for ( i = 0; i < len; i++ ) { x[ i ] = ( rand_double() * 20000.0 ) - 10000.0; y[ i ] = ( rand_double() * 20000.0 ) - 10000.0; @@ -120,6 +122,8 @@ static double benchmark1( int iterations, int len ) { if ( v != v ) { printf( "should not return NaN\n" ); } + free( x ); + free( y ); return elapsed; } @@ -132,12 +136,14 @@ static double benchmark1( int iterations, int len ) { */ static double benchmark2( int iterations, int len ) { double elapsed; - double x[ len ]; - double y[ len ]; + double *x; + double *y; double v; double t; int i; + x = (double *) malloc( len * sizeof( double ) ); + y = (double *) malloc( len * sizeof( double ) ); for ( i = 0; i < len; i++ ) { x[ i ] = ( rand_double() * 20000.0 ) - 10000.0; y[ i ] = ( rand_double() * 20000.0 ) - 10000.0; @@ -156,6 +162,8 @@ static double benchmark2( int iterations, int len ) { if ( v != v ) { printf( "should not return NaN\n" ); } + free( x ); + free( y ); return elapsed; }