mirror of
https://github.com/moparisthebest/curl
synced 2024-12-24 09:08:49 -05:00
tool_parse_cfg: Avoid 2 fopen() for WIN32
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.
This commit is contained in:
parent
9ad313dcb8
commit
8144ba38c3
@ -46,7 +46,7 @@ static char *my_get_line(FILE *fp);
|
||||
/* 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;
|
||||
@ -69,7 +69,6 @@ int parseconfig(const char *filename, struct GlobalConfig *global)
|
||||
*/
|
||||
file = fopen(filebuffer, FOPEN_READTEXT);
|
||||
if(file != NULL) {
|
||||
fclose(file);
|
||||
filename = filebuffer;
|
||||
}
|
||||
else {
|
||||
@ -110,7 +109,9 @@ int parseconfig(const char *filename, struct GlobalConfig *global)
|
||||
#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;
|
||||
|
Loading…
Reference in New Issue
Block a user