Skip to content

Commit 2c9f492

Browse files
GeoDaoyukgryte
andauthored
chore: fix C lint errors
PR-URL: #8217 Closes: #8216 Co-authored-by: Athan Reines <kgryte@gmail.com> Reviewed-by: Athan Reines <kgryte@gmail.com>
1 parent 28a47b4 commit 2c9f492

1 file changed

Lines changed: 10 additions & 3 deletions

File tree

lib/node_modules/@stdlib/math/strided/special/dmsktrunc/benchmark/c/benchmark.length.c

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -115,19 +115,23 @@ float rand_uniformf( float a, float b ) {
115115
*/
116116
static double benchmark( int iterations, int len ) {
117117
double elapsed;
118-
uint8_t m[ len ];
119-
double x[ len ];
120-
double y[ len ];
118+
uint8_t *m;
119+
double *x;
120+
double *y;
121121
double t;
122122
int i;
123123

124+
x = (double *) malloc( len * sizeof( double ) );
125+
y = (double *) malloc( len * sizeof( double ) );
126+
m = (uint8_t *) malloc( len * sizeof( uint8_t ) );
124127
for ( i = 0; i < len; i++ ) {
125128
x[ i ] = rand_uniform( -10.0, 10.0 );
126129
y[ i ] = 0.0;
127130
m[ i ] = 0;
128131
}
129132
t = tic();
130133
for ( i = 0; i < iterations; i++ ) {
134+
// cppcheck-suppress uninitvar
131135
stdlib_strided_dmsktrunc( len, x, 1, m, 1, y, 1 );
132136
if ( y[ 0 ] != y[ 0 ] ) {
133137
printf( "should not return NaN\n" );
@@ -138,6 +142,9 @@ static double benchmark( int iterations, int len ) {
138142
if ( y[ 0 ] != y[ 0 ] ) {
139143
printf( "should not return NaN\n" );
140144
}
145+
free( x );
146+
free( y );
147+
free( m );
141148
return elapsed;
142149
}
143150

0 commit comments

Comments
 (0)