1818
1919#include "stdlib/stats/strided/dmskmin.h"
2020#include <stdlib.h>
21+ #include <stdint.h>
2122#include <stdio.h>
2223#include <math.h>
2324#include <time.h>
@@ -95,14 +96,15 @@ static double rand_double( void ) {
9596* @return elapsed time in seconds
9697*/
9798static double benchmark1 ( int iterations , int len ) {
98- unsigned char mask [ len ];
9999 double elapsed ;
100+ uint8_t * mask ;
100101 double * x ;
101102 double v ;
102103 double t ;
103104 int i ;
104105
105106 x = (double * ) malloc ( len * sizeof ( double ) );
107+ mask = (uint8_t * ) malloc ( len * sizeof ( uint8_t ) );
106108 for ( i = 0 ; i < len ; i ++ ) {
107109 if ( rand_double () < 0.2 ) {
108110 mask [ i ] = 1 ; // missing
@@ -126,6 +128,7 @@ static double benchmark1( int iterations, int len ) {
126128 printf ( "should not return NaN\n" );
127129 }
128130 free ( x );
131+ free ( mask );
129132 return elapsed ;
130133}
131134
@@ -137,14 +140,15 @@ static double benchmark1( int iterations, int len ) {
137140* @return elapsed time in seconds
138141*/
139142static double benchmark2 ( int iterations , int len ) {
140- unsigned char mask [ len ];
141143 double elapsed ;
144+ uint8_t * mask ;
142145 double * x ;
143146 double v ;
144147 double t ;
145148 int i ;
146149
147150 x = (double * ) malloc ( len * sizeof ( double ) );
151+ mask = (uint8_t * ) malloc ( len * sizeof ( uint8_t ) );
148152 for ( i = 0 ; i < len ; i ++ ) {
149153 if ( rand_double () < 0.2 ) {
150154 mask [ i ] = 1 ; // missing
@@ -168,6 +172,7 @@ static double benchmark2( int iterations, int len ) {
168172 printf ( "should not return NaN\n" );
169173 }
170174 free ( x );
175+ free ( mask );
171176 return elapsed ;
172177}
173178
0 commit comments