aboutsummaryrefslogtreecommitdiffstats
path: root/src/ConfigFile.cxx
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2013-01-30 22:37:17 +0100
committerMax Kellermann <max@duempel.org>2013-01-30 22:39:24 +0100
commit378ebad1c8d7079b41319600f13c1c884d6c693a (patch)
treef65564ce3a0fffde7fd0bdbf1c9040de3a15041e /src/ConfigFile.cxx
parente44e0fab9f0851d5a369778923c03701e31b9e79 (diff)
downloadmpd-378ebad1c8d7079b41319600f13c1c884d6c693a.tar.gz
mpd-378ebad1c8d7079b41319600f13c1c884d6c693a.tar.xz
mpd-378ebad1c8d7079b41319600f13c1c884d6c693a.zip
ConfigData: use simple linked list instead of GSList
Diffstat (limited to 'src/ConfigFile.cxx')
-rw-r--r--src/ConfigFile.cxx23
1 files changed, 18 insertions, 5 deletions
diff --git a/src/ConfigFile.cxx b/src/ConfigFile.cxx
index d5b539e7a..695e7803e 100644
--- a/src/ConfigFile.cxx
+++ b/src/ConfigFile.cxx
@@ -137,6 +137,19 @@ config_read_block(FILE *fp, int *count, char *string, GError **error_r)
}
}
+gcc_nonnull_all
+static void
+Append(config_param *&head, config_param *p)
+{
+ assert(p->next == nullptr);
+
+ config_param **i = &head;
+ while (*i != nullptr)
+ i = &(*i)->next;
+
+ *i = p;
+}
+
static bool
ReadConfigFile(ConfigData &config_data, FILE *fp, GError **error_r)
{
@@ -179,12 +192,12 @@ ReadConfigFile(ConfigData &config_data, FILE *fp, GError **error_r)
return false;
}
- const unsigned i = ParseConfigOptionName(name);
+ const unsigned i = unsigned(o);
const ConfigTemplate &option = config_templates[i];
- GSList *&params = config_data.params[i];
+ config_param *&head = config_data.params[i];
- if (params != NULL && !option.repeatable) {
- param = (struct config_param *)params->data;
+ if (head != nullptr && !option.repeatable) {
+ param = head;
g_set_error(error_r, config_quark(), 0,
"config parameter \"%s\" is first defined "
"on line %i and redefined on line %i\n",
@@ -244,7 +257,7 @@ ReadConfigFile(ConfigData &config_data, FILE *fp, GError **error_r)
param = new config_param(value, count);
}
- params = g_slist_append(params, param);
+ Append(head, param);
}
return true;