Ticket #886: read_file-integer-types-fix.diff
File read_file-integer-types-fix.diff, 1.6 KB (added by , 16 years ago) |
---|
-
lib/util.h
71 71 extern void mysql_timestamp(double, char*); 72 72 73 73 extern void boinc_crash(); 74 extern int read_file_malloc(const char* path, char*& , int max_len=0, bool tail=false);75 extern int read_file_string(const char* path, std::string& , int max_len=0, bool tail=false);74 extern int read_file_malloc(const char* path, char*& buf, size_t max_len=0, bool tail=false); 75 extern int read_file_string(const char* path, std::string& result, size_t max_len=0, bool tail=false); 76 76 77 77 #ifdef _WIN32 78 78 -
lib/util.cpp
306 306 307 307 // read file (at most max_len chars, if nonzero) into malloc'd buf 308 308 // 309 int read_file_malloc(const char* path, char*& buf, int max_len, bool tail) {310 int retval , isize;309 int read_file_malloc(const char* path, char*& buf, size_t max_len, bool tail) { 310 int retval; 311 311 double size; 312 312 313 313 retval = file_size(path, size); … … 328 328 size = max_len; 329 329 } 330 330 #endif 331 isize = (int)size;331 size_t isize = size; 332 332 buf = (char*)malloc(isize+1); 333 333 size_t n = fread(buf, 1, isize, f); 334 334 buf[n] = 0; … … 338 338 339 339 // read file (at most max_len chars, if nonzero) into string 340 340 // 341 int read_file_string(const char* path, string& result, int max_len, bool tail) {341 int read_file_string(const char* path, string& result, size_t max_len, bool tail) { 342 342 result.erase(); 343 343 int retval; 344 344 char* buf;