From 29733020dc5ce96b23c6d86a08c5eb1f73accafa Mon Sep 17 00:00:00 2001 From: Prajjwal Bajpai Date: Sat, 7 Feb 2026 17:36:51 +0530 Subject: [PATCH] bench: refactor to use dynamic memory allocation in `blas/base/saxpy` --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: na - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: missing_dependencies - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../base/saxpy/benchmark/c/benchmark.length.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/base/saxpy/benchmark/c/benchmark.length.c b/lib/node_modules/@stdlib/blas/base/saxpy/benchmark/c/benchmark.length.c index c8ee55530538..ef2095b94af9 100644 --- a/lib/node_modules/@stdlib/blas/base/saxpy/benchmark/c/benchmark.length.c +++ b/lib/node_modules/@stdlib/blas/base/saxpy/benchmark/c/benchmark.length.c @@ -96,11 +96,13 @@ static float rand_float( void ) { */ static double benchmark1( int iterations, int len ) { double elapsed; - float x[ len ]; - float y[ len ]; + float *x; + float *y; double t; int i; + x = (float *) malloc( len * sizeof( float ) ); + y = (float *) malloc( len * sizeof( float ) ); for ( i = 0; i < len; i++ ) { x[ i ] = ( rand_float()*100.0f ) - 200.0f; y[ i ] = ( rand_float()*10000.0f ) - 20000.0f; @@ -117,6 +119,8 @@ static double benchmark1( int iterations, int len ) { if ( y[ 0 ] != y[ 0 ] ) { printf( "should not return NaN\n" ); } + free( x ); + free( y ); return elapsed; } @@ -129,11 +133,13 @@ static double benchmark1( int iterations, int len ) { */ static double benchmark2( int iterations, int len ) { double elapsed; - float x[ len ]; - float y[ len ]; + float *x; + float *y; double t; int i; + x = (float *) malloc( len * sizeof( float ) ); + y = (float *) malloc( len * sizeof( float ) ); for ( i = 0; i < len; i++ ) { x[ i ] = ( rand_float()*100.0f ) - 200.0f; y[ i ] = ( rand_float()*10000.0f ) - 20000.0f; @@ -150,6 +156,8 @@ static double benchmark2( int iterations, int len ) { if ( y[ 0 ] != y[ 0 ] ) { printf( "should not return NaN\n" ); } + free( x ); + free( y ); return elapsed; }