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>
Этот коммит содержится в:
родитель
5a67008194
Коммит
709150fe77
@ -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;
|
||||
}
|
||||
|
||||
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
|
||||
|
@ -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);
|
||||
|
Загрузка…
x
Ссылка в новой задаче
Block a user