Skip to content

Commit 6d81871

Browse files
committed
bench: refactor to use dynamic memory allocation in stats/strided/dmean
--- 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 ---
1 parent 5b02960 commit 6d81871

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

lib/node_modules/@stdlib/stats/strided/dmean/benchmark/c/benchmark.length.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,11 +96,11 @@ static double rand_double( void ) {
9696
*/
9797
static double benchmark( int iterations, int len ) {
9898
double elapsed;
99-
double x[ len ];
99+
double *x;
100100
double v;
101101
double t;
102102
int i;
103-
103+
x = (double *) malloc( len * sizeof( double ) );
104104
for ( i = 0; i < len; i++ ) {
105105
x[ i ] = ( rand_double() * 20000.0 ) - 10000.0;
106106
}
@@ -117,6 +117,7 @@ static double benchmark( int iterations, int len ) {
117117
if ( v != v ) {
118118
printf( "should not return NaN\n" );
119119
}
120+
free( x );
120121
return elapsed;
121122
}
122123

0 commit comments

Comments
 (0)