summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPatrick McDermott <pj@pehjota.net>2017-10-04 18:26:51 (EDT)
committer Patrick McDermott <pj@pehjota.net>2017-10-04 18:26:51 (EDT)
commit1bfaef2d15ded8c0401df079e32318ea409e6fbe (patch)
tree08737cef28193dee8f35e4f5cac85c9887e12574
parentc5a78ae13d0804ce00861d1439ba21bae2f285a1 (diff)
downloadmarquee-1bfaef2d15ded8c0401df079e32318ea409e6fbe.zip
marquee-1bfaef2d15ded8c0401df079e32318ea409e6fbe.tar.gz
marquee-1bfaef2d15ded8c0401df079e32318ea409e6fbe.tar.bz2
mq_config_get_*(), mq_config_set_*(): Free duplicated group/key strings
And fix return value of mq_config_get_double().
-rw-r--r--src/config.c37
-rw-r--r--src/config.h2
2 files changed, 30 insertions, 9 deletions
diff --git a/src/config.c b/src/config.c
index 12b723e..19c06eb 100644
--- a/src/config.c
+++ b/src/config.c
@@ -139,13 +139,18 @@ mq_config_save(MqConfig *config)
gboolean
mq_config_get_boolean(MqConfig *config, const gchar *name)
{
- gchar *group;
- gchar *key;
+ gchar *group;
+ gchar *key;
+ gboolean value;
split_name(name, &group, &key);
/* TODO: Handle value parsing errors? */
- return g_key_file_get_boolean(config->key_file, group, key, NULL);
+ value = g_key_file_get_boolean(config->key_file, group, key, NULL);
+
+ g_free(group);
+
+ return value;
}
gint
@@ -153,23 +158,33 @@ mq_config_get_integer(MqConfig *config, const gchar *name)
{
gchar *group;
gchar *key;
+ gint value;
split_name(name, &group, &key);
/* TODO: Handle value parsing errors? */
- return g_key_file_get_integer(config->key_file, group, key, NULL);
+ value = g_key_file_get_integer(config->key_file, group, key, NULL);
+
+ g_free(group);
+
+ return value;
}
-gboolean
+gdouble
mq_config_get_double(MqConfig *config, const gchar *name)
{
- gchar *group;
- gchar *key;
+ gchar *group;
+ gchar *key;
+ gdouble value;
split_name(name, &group, &key);
/* TODO: Handle value parsing errors? */
- return g_key_file_get_double(config->key_file, group, key, NULL);
+ value = g_key_file_get_double(config->key_file, group, key, NULL);
+
+ g_free(group);
+
+ return value;
}
void
@@ -182,6 +197,8 @@ mq_config_set_boolean(MqConfig *config, const gchar *name, gboolean value)
g_key_file_set_boolean(config->key_file, group, key, value);
+ g_free(group);
+
set_type_or_run_callbacks(config, name, &value, TYPE_BOOLEAN);
}
@@ -195,6 +212,8 @@ mq_config_set_integer(MqConfig *config, const gchar *name, gint value)
g_key_file_set_integer(config->key_file, group, key, value);
+ g_free(group);
+
set_type_or_run_callbacks(config, name, &value, TYPE_INTEGER);
}
@@ -208,6 +227,8 @@ mq_config_set_double(MqConfig *config, const gchar *name, gdouble value)
g_key_file_set_double(config->key_file, group, key, value);
+ g_free(group);
+
set_type_or_run_callbacks(config, name, &value, TYPE_DOUBLE);
}
diff --git a/src/config.h b/src/config.h
index a5a7bdc..20254e9 100644
--- a/src/config.h
+++ b/src/config.h
@@ -42,7 +42,7 @@ mq_config_get_boolean(MqConfig *config, const gchar *name);
gint
mq_config_get_integer(MqConfig *config, const gchar *name);
-gboolean
+gdouble
mq_config_get_double(MqConfig *config, const gchar *name);
void