From b3795f64ac1fe36c6509d23e802ab74d662968ee Mon Sep 17 00:00:00 2001 From: Omar Mohamed Date: Wed, 24 Dec 2025 22:07:46 +0200 Subject: [PATCH 1/2] bench: refactor to use dynamic memory allocation in strided/base/smskmap2 --- .../base/smskmap2/benchmark/c/benchmark.length.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/lib/node_modules/@stdlib/strided/base/smskmap2/benchmark/c/benchmark.length.c b/lib/node_modules/@stdlib/strided/base/smskmap2/benchmark/c/benchmark.length.c index 371581f8eb5e..fc60d9561984 100644 --- a/lib/node_modules/@stdlib/strided/base/smskmap2/benchmark/c/benchmark.length.c +++ b/lib/node_modules/@stdlib/strided/base/smskmap2/benchmark/c/benchmark.length.c @@ -107,14 +107,18 @@ static float addf( const float x, const float y ) { * @return elapsed time in seconds */ static double benchmark( int iterations, int len ) { - uint8_t m[ len ]; + uint8_t *m; double elapsed; - float x[ len ]; - float y[ len ]; - float z[ len ]; + float *x; + float *y; + float *z; double t; int i; + m = (uint8_t *)malloc( len * sizeof( uint8_t ) ); + x = (float *)malloc( len * sizeof( float ) ); + y = (float *)malloc( len * sizeof( float ) ); + z = (float *)malloc( len * sizeof( float ) ); for ( i = 0; i < len; i++ ) { x[ i ] = ( rand_float()*200.0f ) - 100.0f; y[ i ] = ( rand_float()*200.0f ) - 100.0f; @@ -133,6 +137,10 @@ static double benchmark( int iterations, int len ) { if ( z[ i%len ] != z[ i%len ] ) { printf( "should not return NaN\n" ); } + free( m ); + free( x ); + free( y ); + free( z ); return elapsed; } From 87cbf23efa579cb8df2cec065345477e34de7263 Mon Sep 17 00:00:00 2001 From: Athan Date: Wed, 24 Dec 2025 14:15:30 -0800 Subject: [PATCH 2/2] style: reorder variable declarations Signed-off-by: Athan --- .../strided/base/smskmap2/benchmark/c/benchmark.length.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/strided/base/smskmap2/benchmark/c/benchmark.length.c b/lib/node_modules/@stdlib/strided/base/smskmap2/benchmark/c/benchmark.length.c index fc60d9561984..cf1a9df5e1bf 100644 --- a/lib/node_modules/@stdlib/strided/base/smskmap2/benchmark/c/benchmark.length.c +++ b/lib/node_modules/@stdlib/strided/base/smskmap2/benchmark/c/benchmark.length.c @@ -107,8 +107,8 @@ static float addf( const float x, const float y ) { * @return elapsed time in seconds */ static double benchmark( int iterations, int len ) { - uint8_t *m; double elapsed; + uint8_t *m; float *x; float *y; float *z;