File.cpp (pymol-open-source-2.2.0) | : | File.cpp (pymol-open-source-2.3.0) | ||
---|---|---|---|---|
skipping to change at line 38 | skipping to change at line 38 | |||
/* | /* | |||
* Allocate memory and read the entire file from the given file pointer. | * Allocate memory and read the entire file from the given file pointer. | |||
* The file size is stored into the size pointer if not NULL. | * The file size is stored into the size pointer if not NULL. | |||
*/ | */ | |||
static char * fgetcontents(FILE *fp, long *size) { | static char * fgetcontents(FILE *fp, long *size) { | |||
long filesize = fgetsize(fp); | long filesize = fgetsize(fp); | |||
char *contents = (char*) mmalloc(filesize + 255); | char *contents = (char*) mmalloc(filesize + 255); | |||
if (!contents) | if (!contents) | |||
return NULL; | return nullptr; | |||
if (1 != fread(contents, filesize, 1, fp)) { | if (1 != fread(contents, filesize, 1, fp)) { | |||
mfree(contents); | mfree(contents); | |||
return NULL; | return nullptr; | |||
} | } | |||
if (size) | if (size) | |||
*size = filesize; | *size = filesize; | |||
contents[filesize] = '\0'; | contents[filesize] = '\0'; | |||
return contents; | return contents; | |||
} | } | |||
#ifdef _WIN32 | #ifdef _WIN32 | |||
skipping to change at line 81 | skipping to change at line 81 | |||
/* | /* | |||
* Allocate memory and read the entire file for the given filename. | * Allocate memory and read the entire file for the given filename. | |||
* The file size is stored into the size pointer if not NULL. | * The file size is stored into the size pointer if not NULL. | |||
*/ | */ | |||
char * FileGetContents(const char *filename, long *size) { | char * FileGetContents(const char *filename, long *size) { | |||
char *contents; | char *contents; | |||
FILE *fp = pymol_fopen(filename, "rb"); | FILE *fp = pymol_fopen(filename, "rb"); | |||
if (!fp) | if (!fp) | |||
return NULL; | return nullptr; | |||
contents = fgetcontents(fp, size); | contents = fgetcontents(fp, size); | |||
fclose(fp); | fclose(fp); | |||
return contents; | return contents; | |||
} | } | |||
End of changes. 3 change blocks. | ||||
3 lines changed or deleted | 3 lines changed or added |