Skip to content

Commit fbf698e

Browse files
committed
bench: refactor to use dynamic memory allocation in strided/base/dmap
--- 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: passed - 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 ---
1 parent a0ef914 commit fbf698e

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

lib/node_modules/@stdlib/strided/base/dmap/benchmark/c/benchmark.length.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,11 +106,13 @@ static double identity( const double x ) {
106106
*/
107107
static double benchmark( int iterations, int len ) {
108108
double elapsed;
109-
double x[ len ];
110-
double y[ len ];
109+
double *x;
110+
double *y;
111111
double t;
112112
int i;
113113

114+
x = (double *)malloc( len * sizeof( double ) );
115+
y = (double *)malloc( len * sizeof( double ) );
114116
for ( i = 0; i < len; i++ ) {
115117
x[ i ] = ( rand_double()*200.0 ) - 100.0;
116118
y[ i ] = 0.0;
@@ -128,6 +130,8 @@ static double benchmark( int iterations, int len ) {
128130
if ( y[ i%len ] != y[ i%len ] ) {
129131
printf( "should not return NaN\n" );
130132
}
133+
free( x );
134+
free( y );
131135
return elapsed;
132136
}
133137

0 commit comments

Comments
 (0)