Ticket #886: read_file-integer-types-fix.diff

File read_file-integer-types-fix.diff, 1.6 KB (added by Nicolas, 15 years ago)
  • lib/util.h

     
    7171extern void mysql_timestamp(double, char*);
    7272
    7373extern 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);
     74extern int read_file_malloc(const char* path, char*& buf, size_t max_len=0, bool tail=false);
     75extern int read_file_string(const char* path, std::string& result, size_t max_len=0, bool tail=false);
    7676
    7777#ifdef _WIN32
    7878
  • lib/util.cpp

     
    306306
    307307// read file (at most max_len chars, if nonzero) into malloc'd buf
    308308//
    309 int read_file_malloc(const char* path, char*& buf, int max_len, bool tail) {
    310     int retval, isize;
     309int read_file_malloc(const char* path, char*& buf, size_t max_len, bool tail) {
     310    int retval;
    311311    double size;
    312312
    313313    retval = file_size(path, size);
     
    328328        size = max_len;
    329329    }
    330330#endif
    331     isize = (int) size;
     331    size_t isize = size;
    332332    buf = (char*)malloc(isize+1);
    333333    size_t n = fread(buf, 1, isize, f);
    334334    buf[n] = 0;
     
    338338
    339339// read file (at most max_len chars, if nonzero) into string
    340340//
    341 int read_file_string(const char* path, string& result, int max_len, bool tail) {
     341int read_file_string(const char* path, string& result, size_t max_len, bool tail) {
    342342    result.erase();
    343343    int retval;
    344344    char* buf;