Cleanup for config_file_write
This commit is contained in:
parent
ff4dca86f9
commit
059354de2f
|
@ -912,12 +912,10 @@ void config_set_bool(config_file_t *conf, const char *key, bool val)
|
||||||
|
|
||||||
bool config_file_write(config_file_t *conf, const char *path)
|
bool config_file_write(config_file_t *conf, const char *path)
|
||||||
{
|
{
|
||||||
FILE* file = NULL;
|
|
||||||
void* buf = NULL;
|
|
||||||
|
|
||||||
if (!string_is_empty(path))
|
if (!string_is_empty(path))
|
||||||
{
|
{
|
||||||
file = fopen(path, "wb");
|
void* buf = NULL;
|
||||||
|
FILE *file = fopen(path, "wb");
|
||||||
if (!file)
|
if (!file)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
@ -926,15 +924,14 @@ bool config_file_write(config_file_t *conf, const char *path)
|
||||||
setvbuf(file, (char*)buf, _IOFBF, 0x4000);
|
setvbuf(file, (char*)buf, _IOFBF, 0x4000);
|
||||||
|
|
||||||
config_file_dump(conf, file);
|
config_file_dump(conf, file);
|
||||||
|
|
||||||
|
if (file != stdout)
|
||||||
|
fclose(file);
|
||||||
|
free(buf);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
config_file_dump(conf, stdout);
|
config_file_dump(conf, stdout);
|
||||||
|
|
||||||
if (file && file != stdout)
|
|
||||||
fclose(file);
|
|
||||||
if (buf)
|
|
||||||
free(buf);
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue