From 2c258a2b1ad4db9c3752804d0086fc706f92ec88 Mon Sep 17 00:00:00 2001 From: Patrick McDermott Date: Thu, 05 Oct 2017 19:24:16 -0400 Subject: src/config.c: Move a static function --- diff --git a/src/config.c b/src/config.c index 85487c0..6074773 100644 --- a/src/config.c +++ b/src/config.c @@ -55,48 +55,6 @@ struct item { struct callbacks *callbacks; }; -static void -set_type_or_run_callbacks(MqConfig *config, const gchar *name, gpointer value, - enum type type) -{ - struct item *item; - struct callbacks *cbs; - - if (!config->types_and_cbs_set) { - item = g_malloc(sizeof(*item)); - item->type = type; - item->callbacks = NULL; - g_hash_table_insert(config->types_and_cbs, g_strdup(name), - item); - } else { - item = g_hash_table_lookup(config->types_and_cbs, name); - for (cbs = item->callbacks; cbs; cbs = cbs->next) { - switch (item->type) { - case TYPE_BOOLEAN: - cbs->cb.boolean_cb(name, - *((gboolean *) value), - cbs->user_data); - break; - case TYPE_INTEGER: - cbs->cb.integer_cb(name, - *((gint *) value), - cbs->user_data); - break; - case TYPE_DOUBLE: - cbs->cb.double_cb(name, - *((gdouble *) value), - cbs->user_data); - break; - case TYPE_STRING: - cbs->cb.string_cb(name, - (gchar *) value, - cbs->user_data); - break; - } - } - } -} - #define SET_BOOL(NAME, VALUE) mq_config_set_boolean(config, NAME, VALUE) #define SET_INT( NAME, VALUE) mq_config_set_integer(config, NAME, VALUE) #define SET_DBL( NAME, VALUE) mq_config_set_double (config, NAME, VALUE) @@ -324,6 +282,48 @@ mq_config_get_string(MqConfig *config, const gchar *name) return value; } +static void +set_type_or_run_callbacks(MqConfig *config, const gchar *name, gpointer value, + enum type type) +{ + struct item *item; + struct callbacks *cbs; + + if (!config->types_and_cbs_set) { + item = g_malloc(sizeof(*item)); + item->type = type; + item->callbacks = NULL; + g_hash_table_insert(config->types_and_cbs, g_strdup(name), + item); + } else { + item = g_hash_table_lookup(config->types_and_cbs, name); + for (cbs = item->callbacks; cbs; cbs = cbs->next) { + switch (item->type) { + case TYPE_BOOLEAN: + cbs->cb.boolean_cb(name, + *((gboolean *) value), + cbs->user_data); + break; + case TYPE_INTEGER: + cbs->cb.integer_cb(name, + *((gint *) value), + cbs->user_data); + break; + case TYPE_DOUBLE: + cbs->cb.double_cb(name, + *((gdouble *) value), + cbs->user_data); + break; + case TYPE_STRING: + cbs->cb.string_cb(name, + (gchar *) value, + cbs->user_data); + break; + } + } + } +} + void mq_config_set_boolean(MqConfig *config, const gchar *name, gboolean value) { -- cgit v0.9.1