Skip to content

Commit

Permalink
Make array lengths optional
Browse files Browse the repository at this point in the history
Similarly to underlying g_key_file_xxx() functions.
  • Loading branch information
spiiroin committed Jan 3, 2013
1 parent 7e42b1a commit c0ec8bf
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions mce-conf.c
Expand Up @@ -125,7 +125,7 @@ gint mce_conf_get_int(const gchar *group, const gchar *key,
*
* @param group The configuration group to get the value from
* @param key The configuration key to get the value of
* @param length The length of the list
* @param length The length of the list, or NULL if not needed
* @param keyfileptr A keyfile pointer, or NULL to use the default keyfile
* @return The configuration value on success, NULL on failure
*/
Expand All @@ -141,7 +141,8 @@ gint *mce_conf_get_int_list(const gchar *group, const gchar *key,
"Could not get config key %s/%s; "
"no configuration file initialised",
group, key);
*length = 0;
if( length )
*length = 0;
goto EXIT;
} else {
keyfileptr = keyfile;
Expand All @@ -155,7 +156,8 @@ gint *mce_conf_get_int_list(const gchar *group, const gchar *key,
mce_log(LL_WARN,
"Could not get config key %s/%s; %s",
group, key, error->message);
*length = 0;
if( length )
*length = 0;
}

g_clear_error(&error);
Expand Down Expand Up @@ -221,7 +223,7 @@ gchar *mce_conf_get_string(const gchar *group, const gchar *key,
*
* @param group The configuration group to get the value from
* @param key The configuration key to get the value of
* @param length The length of the list
* @param length The length of the list, or NULL if not needed
* @param keyfileptr A keyfile pointer, or NULL to use the default keyfile
* @return The configuration value on success, NULL on failure
*/
Expand All @@ -237,7 +239,8 @@ gchar **mce_conf_get_string_list(const gchar *group, const gchar *key,
"Could not get config key %s/%s; "
"no configuration file initialised",
group, key);
*length = 0;
if( length )
*length = 0;
goto EXIT;
} else {
keyfileptr = keyfile;
Expand All @@ -251,7 +254,8 @@ gchar **mce_conf_get_string_list(const gchar *group, const gchar *key,
mce_log(LL_WARN,
"Could not get config key %s/%s; %s",
group, key, error->message);
*length = 0;
if( length )
*length = 0;
}

g_clear_error(&error);
Expand All @@ -272,7 +276,8 @@ gchar **mce_conf_get_keys(const gchar *group, gsize *length,
"Could not get config keys %s; "
"no configuration file initialised",
group);
*length = 0;
if( length )
*length = 0;
goto EXIT;
} else {
keyfileptr = keyfile;
Expand All @@ -285,7 +290,8 @@ gchar **mce_conf_get_keys(const gchar *group, gsize *length,
mce_log(LL_WARN,
"Could not get config keys %s; %s",
group, error->message);
*length = 0;
if( length )
*length = 0;
}

g_clear_error(&error);
Expand Down

0 comments on commit c0ec8bf

Please sign in to comment.