Fixed return value of mc_config_new() function

Also *len parameter always setting up in mc_config_get_keys() and mc_config_get_groups() functions.

Signed-off-by: Slava Zanko <slavazanko@gmail.com>
This commit is contained in:
Slava Zanko 2009-06-24 12:48:32 +03:00 committed by Andrew Borodin
parent 5a67008194
commit 709150fe77
2 changed files with 8 additions and 9 deletions

View File

@ -66,18 +66,15 @@ mc_config_init (const gchar * ini_path)
return mc_config;
}
if (((mc_stat (ini_path, &st) == 0) && (st.st_size == 0))
|| g_key_file_load_from_file
(mc_config->handle, ini_path, G_KEY_FILE_KEEP_COMMENTS, NULL))
if (mc_stat (ini_path, &st) && st.st_size)
{
/* file is empty or normal */
mc_config->ini_path = g_strdup (ini_path);
return mc_config;
/* file present and not empty */
g_key_file_load_from_file
(mc_config->handle, ini_path, G_KEY_FILE_KEEP_COMMENTS, NULL);
}
g_key_file_free (mc_config->handle);
g_free (mc_config);
return NULL;
mc_config->ini_path = g_strdup (ini_path);
return mc_config;
}
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

View File

@ -42,6 +42,7 @@ mc_config_get_groups (mc_config_t * mc_config, gsize * len)
if (!mc_config)
{
ret = g_try_malloc0 (sizeof (gchar **));
*len=0;
return ret;
}
ret = g_key_file_get_groups (mc_config->handle, len);
@ -62,6 +63,7 @@ mc_config_get_keys (mc_config_t * mc_config, const gchar * group, gsize * len)
if (!mc_config || !group)
{
ret = g_try_malloc0 (sizeof (gchar **));
*len=0;
return ret;
}
ret = g_key_file_get_keys (mc_config->handle, group, len, NULL);