From f392135bc44e66558fe19c3418964b7e3c0820b2 Mon Sep 17 00:00:00 2001 From: Patrick McDermott Date: Wed, 04 Oct 2017 13:50:53 -0400 Subject: src/config.c: Move hash table setup into new function --- (limited to 'src/config.c') diff --git a/src/config.c b/src/config.c index 18e6875..701dc35 100644 --- a/src/config.c +++ b/src/config.c @@ -45,26 +45,33 @@ split_name(const gchar *name, gchar **group, gchar **key) } static void -set_boolean(MqConfig *config, const gchar *name, gboolean value) +add_type_and_callbacks(MqConfig *config, const gchar *name, Type type) { - gchar *group; - gchar *key; ConfigItem *item; - split_name(name, &group, &key); - - g_key_file_set_boolean(config->key_file, group, name, value); - if (!config->types_and_cbs_set) { item = g_malloc(sizeof(*item)); - item->type = TYPE_BOOLEAN; - item-callbacks = NULL; + item->type = type; + item->callbacks = NULL; g_hash_table_insert(config->types_and_cbs, g_strdup(name), item); } } static void +set_boolean(MqConfig *config, const gchar *name, gboolean value) +{ + gchar *group; + gchar *key; + + split_name(name, &group, &key); + + g_key_file_set_boolean(config->key_file, group, name, value); + + add_type_and_callbacks(config, name, TYPE_BOOLEAN); +} + +static void set_defaults(MqConfig *config) { config->types_and_cbs_set = FALSE; -- cgit v0.9.1