Using the memdebug.h mem-leak feature, I noticed 2 calls like:
FILE tool_parsecfg.c:70 fopen("c:\Users\Gisle\AppData\Roaming\_curlrc","rt")
FILE tool_parsecfg.c:114 fopen("c:\Users\Gisle\AppData\Roaming\_curlrc","rt")
No need for 'fopen(), 'fclose()' and a 'fopen()' yet again.
/* return 0 on everything-is-fine, and non-zero otherwise */
int parseconfig(const char *filename, struct GlobalConfig *global)
{
- FILE *file;
+ FILE *file = NULL;
char filebuffer[512];
bool usedarg = FALSE;
int rc = 0;
*/
file = fopen(filebuffer, FOPEN_READTEXT);
if(file != NULL) {
- fclose(file);
filename = filebuffer;
}
else {
#endif
}
- if(strcmp(filename, "-"))
+ if(file != NULL) /* WIN32: no need to fopen() again */
+ ;
+ else if(strcmp(filename, "-"))
file = fopen(filename, FOPEN_READTEXT);
else
file = stdin;