1111#endif
1212#ifdef WIN32 // means WIN64, too, oddly
1313 #include <windows.h>
14- #include <stdbool.h> // true and false
1514#else
1615 #include <sys/mman.h> // mmap
1716 #include <sys/stat.h> // fstat for filesize
1817 #include <fcntl.h> // open
1918 #include <unistd.h> // close
20- #include <stdbool.h> // true and false
2119 #include <ctype.h> // isspace
2220 #include <errno.h> // errno
2321 #include <string.h> // strerror
@@ -407,11 +405,10 @@ double wallclock(void)
407405 * multiple threads at the same time, or hold on to the value returned for
408406 * extended periods of time.
409407 */
410- static const char * filesize_to_str (size_t fsize )
408+ static const char * filesize_to_str (const size_t fsize )
411409{
412410 static const char suffixes [] = {'T' , 'G' , 'M' , 'K' };
413411 static char output [100 ];
414- size_t lsize = fsize ;
415412 for (int i = 0 ; i <= sizeof (suffixes ); i ++ ) {
416413 int shift = (sizeof (suffixes ) - i ) * 10 ;
417414 if ((fsize >> shift ) == 0 ) continue ;
@@ -422,17 +419,17 @@ static const char* filesize_to_str(size_t fsize)
422419 if (ndigits == 0 || (fsize == (fsize >> shift << shift ))) {
423420 if (i < sizeof (suffixes )) {
424421 snprintf (output , sizeof (output ), "%" PRIu64 "%cB (%" PRIu64 " bytes)" , // # notranslate
425- (uint64_t )( lsize >> shift ), suffixes [i ], ( uint64_t ) lsize );
422+ (fsize >> shift ), suffixes [i ], fsize );
426423 return output ;
427424 }
428425 } else {
429426 snprintf (output , sizeof (output ), "%.*f%cB (%" PRIu64 " bytes)" , // # notranslate
430- ndigits , (double )fsize / (1LL << shift ), suffixes [i ], ( uint64_t ) lsize );
427+ ndigits , (double )fsize / (1LL << shift ), suffixes [i ], fsize );
431428 return output ;
432429 }
433430 }
434431 if (fsize == 1 ) return "1 byte" ;
435- snprintf (output , sizeof (output ), "%" PRIu64 " bytes" , ( uint64_t ) lsize ); // # notranslate
432+ snprintf (output , sizeof (output ), "%" PRIu64 " bytes" , fsize ); // # notranslate
436433 return output ;
437434}
438435
@@ -1197,7 +1194,7 @@ static reader_fun_t fun[NUMTYPE] = {
11971194
11981195static int disabled_parsers [NUMTYPE ] = {0 };
11991196
1200- static int detect_types ( const char * * pch , int8_t type [] , int ncol , bool * bumped ) {
1197+ static int detect_types (const char * * pch , int ncol , bool * bumped ) {
12011198 // used in sampling column types and whether column names are present
12021199 // test at most ncol fields. If there are fewer fields, the data read step later
12031200 // will error (if fill==false) when the line number is known, so we don't need to handle that here.
@@ -1882,8 +1879,8 @@ int freadMain(freadMainArgs _args) {
18821879 if (verbose ) DTPRINT (_ ("[07] Detect column types, dec, good nrow estimate and whether first row is column names\n" ));
18831880 if (verbose && args .header != NA_BOOL8 ) DTPRINT (_ (" 'header' changed by user from 'auto' to %s\n" ), args .header ?"true" :"false" );
18841881
1885- type = malloc (sizeof (* type ) * ( size_t ) ncol );
1886- tmpType = malloc (sizeof (* tmpType ) * ( size_t ) ncol ); // used i) in sampling to not stop on errors when bad jump point and ii) when accepting user overrides
1882+ type = malloc (sizeof (* type ) * ncol );
1883+ tmpType = malloc (sizeof (* tmpType ) * ncol ); // used i) in sampling to not stop on errors when bad jump point and ii) when accepting user overrides
18871884 if (!type || !tmpType ) {
18881885 free (type ); free (tmpType ); // # nocov
18891886 STOP (_ ("Failed to allocate 2 x %d bytes for type and tmpType: %s" ), ncol , strerror (errno )); // # nocov
@@ -1953,7 +1950,7 @@ int freadMain(freadMainArgs _args) {
19531950
19541951 while (ch < eof && jumpLine ++ < jumpLines ) {
19551952 const char * lineStart = ch ;
1956- int thisNcol = detect_types (& ch , tmpType , ncol , & bumped );
1953+ int thisNcol = detect_types (& ch , ncol , & bumped );
19571954 if (thisNcol == 0 && skipEmptyLines ) {
19581955 if (eol (& ch )) ch ++ ;
19591956 continue ;
@@ -2008,7 +2005,7 @@ int freadMain(freadMainArgs _args) {
20082005 if (dec == '\0' ) { // in files without jumps, dec could still be undecided
20092006 linesForDecDot = 0 ;
20102007 }
2011- detect_types (& ch , tmpType , ncol , & bumped );
2008+ detect_types (& ch , ncol , & bumped );
20122009 if (dec == '\0' ) {
20132010 dec = linesForDecDot < 0 ? ',' : '.' ;
20142011 if (verbose ) {
@@ -2199,9 +2196,9 @@ int freadMain(freadMainArgs _args) {
21992196 rowSize1 = 0 ;
22002197 rowSize4 = 0 ;
22012198 rowSize8 = 0 ;
2202- size = malloc (sizeof (* size ) * ( size_t ) ncol ); // TODO: remove size[] when we implement Pasha's idea to += size inside processor
2199+ size = malloc (sizeof (* size ) * ncol ); // TODO: remove size[] when we implement Pasha's idea to += size inside processor
22032200 if (!size )
2204- STOP (_ ("Failed to allocate %d bytes for '%s': %s" ), (int )(sizeof (* size ) * ( size_t ) ncol ), "size" , strerror (errno )); // # nocov
2201+ STOP (_ ("Failed to allocate %d bytes for '%s': %s" ), (int )(sizeof (* size ) * ncol ), "size" , strerror (errno )); // # nocov
22052202 nStringCols = 0 ;
22062203 nNonStringCols = 0 ;
22072204 for (int j = 0 ; j < ncol ; j ++ ) {
@@ -2640,9 +2637,9 @@ int freadMain(freadMainArgs _args) {
26402637 DTPRINT (_ (" Provided number of fill columns: %d but only found %d\n" ), ncol , max_col );
26412638 DTPRINT (_ (" Dropping %d overallocated columns\n" ), ndropFill );
26422639 }
2643- dropFill = malloc (sizeof (* dropFill ) * ( size_t ) ndropFill );
2640+ dropFill = malloc (sizeof (* dropFill ) * ndropFill );
26442641 if (!dropFill )
2645- STOP (_ ("Failed to allocate %d bytes for '%s'." ), (int )(ndropFill * sizeof (int ) ), "dropFill" ); // # nocov
2642+ STOP (_ ("Failed to allocate %d bytes for '%s'." ), (int )(sizeof (* dropFill ) * ndropFill ), "dropFill" ); // # nocov
26462643 int i = 0 ;
26472644 for (int j = max_col ; j < ncol ; ++ j ) {
26482645 type [j ] = CT_DROP ;
0 commit comments