utf8-everywhere: Forgot the g_free's and the g_unlink / g_rename.

This commit is contained in:
Arnav Singh 2012-11-12 00:06:05 -08:00
parent 0f26470169
commit 6ec040f5c9
1 changed files with 11 additions and 11 deletions

View File

@ -844,23 +844,23 @@ int
save_config (void) save_config (void)
{ {
int fh, i; int fh, i;
char *new_config, *config; char *config, *new_config;
check_prefs_dir (); check_prefs_dir ();
config = default_file (); config = default_file ();
new_config = g_strdup_printf ("%s.new", config); new_config = g_strconcat (config, ".new");
fh = g_open (new_config, OFLAGS | O_TRUNC | O_WRONLY | O_CREAT, 0600); fh = g_open (new_config, OFLAGS | O_TRUNC | O_WRONLY | O_CREAT, 0600);
if (fh == -1) if (fh == -1)
{ {
free (new_config); g_free (new_config);
return 0; return 0;
} }
if (!cfg_put_str (fh, "version", PACKAGE_VERSION)) if (!cfg_put_str (fh, "version", PACKAGE_VERSION))
{ {
free (new_config); g_free (new_config);
return 0; return 0;
} }
@ -872,7 +872,7 @@ save_config (void)
case TYPE_STR: case TYPE_STR:
if (!cfg_put_str (fh, vars[i].name, (char *) &prefs + vars[i].offset)) if (!cfg_put_str (fh, vars[i].name, (char *) &prefs + vars[i].offset))
{ {
free (new_config); g_free (new_config);
return 0; return 0;
} }
break; break;
@ -880,7 +880,7 @@ save_config (void)
case TYPE_BOOL: case TYPE_BOOL:
if (!cfg_put_int (fh, *((int *) &prefs + vars[i].offset), vars[i].name)) if (!cfg_put_int (fh, *((int *) &prefs + vars[i].offset), vars[i].name))
{ {
free (new_config); g_free (new_config);
return 0; return 0;
} }
} }
@ -890,19 +890,19 @@ save_config (void)
if (close (fh) == -1) if (close (fh) == -1)
{ {
free (new_config); g_free (new_config);
return 0; return 0;
} }
#ifdef WIN32 #ifdef WIN32
unlink (config); /* win32 can't rename to an existing file */ g_unlink (config); /* win32 can't rename to an existing file */
#endif #endif
if (rename (new_config, config) == -1) if (g_rename (new_config, config) == -1)
{ {
free (new_config); g_free (new_config);
return 0; return 0;
} }
free (new_config); g_free (new_config);
return 1; return 1;
} }