summaryrefslogtreecommitdiffstats
path: root/bus
diff options
context:
space:
mode:
authorJohn (J5) Palmieri <johnp@redhat.com>2006-10-27 18:30:22 +0000
committerJohn (J5) Palmieri <johnp@redhat.com>2006-10-27 18:30:22 +0000
commitfeb7d3a0f0e2404e81fbe6252864ab599e1fa38d (patch)
tree1d2eda2d7379c650b722ae32593b2cc078fa5663 /bus
parentfd27857e31dc6bd7b78ddddbb6ef3f1162ee0b88 (diff)
* bus/config-parser.c (service_dirs_find_dir,
service_dirs_append_unique_or_free, service_dirs_append_link_unique_or_free): New static methods for only appending unique service directory names into the service directory list (merge_included, bus_config_parser_content): Only add unique service directory names into the list
Diffstat (limited to 'bus')
-rw-r--r--bus/config-parser.c50
1 files changed, 48 insertions, 2 deletions
diff --git a/bus/config-parser.c b/bus/config-parser.c
index 5b923632..b126eb0c 100644
--- a/bus/config-parser.c
+++ b/bus/config-parser.c
@@ -287,6 +287,52 @@ merge_service_context_hash (DBusHashTable *dest,
}
static dbus_bool_t
+service_dirs_find_dir (DBusList **service_dirs,
+ const char *dir)
+{
+ DBusList *link;
+
+ _dbus_assert (dir != NULL);
+
+ for (link = *service_dirs; link; link = link->next)
+ {
+ const char *link_dir;
+
+ link_dir = (const char *)link->data;
+ if (strcmp (dir, link_dir) == 0)
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+static dbus_bool_t
+service_dirs_append_unique_or_free (DBusList **service_dirs,
+ char *dir)
+{
+ if (!service_dirs_find_dir (service_dirs, dir))
+ return _dbus_list_append (service_dirs, dir);
+
+ dbus_free (dir);
+ return TRUE;
+}
+
+static void
+service_dirs_append_link_unique_or_free (DBusList **service_dirs,
+ DBusList *dir_link)
+{
+ if (!service_dirs_find_dir (service_dirs, dir_link->data))
+ {
+ _dbus_list_append_link (service_dirs, dir_link);
+ }
+ else
+ {
+ dbus_free (dir_link->data);
+ _dbus_list_free_link (dir_link);
+ }
+}
+
+static dbus_bool_t
merge_included (BusConfigParser *parser,
BusConfigParser *included,
DBusError *error)
@@ -338,7 +384,7 @@ merge_included (BusConfigParser *parser,
_dbus_list_append_link (&parser->mechanisms, link);
while ((link = _dbus_list_pop_first_link (&included->service_dirs)))
- _dbus_list_append_link (&parser->service_dirs, link);
+ service_dirs_append_link_unique_or_free (&parser->service_dirs, link);
while ((link = _dbus_list_pop_first_link (&included->conf_dirs)))
_dbus_list_append_link (&parser->conf_dirs, link);
@@ -2312,7 +2358,7 @@ bus_config_parser_content (BusConfigParser *parser,
goto nomem;
}
- if (!_dbus_list_append (&parser->service_dirs, s))
+ if (!service_dirs_append_unique_or_free (&parser->service_dirs, s))
{
_dbus_string_free (&full_path);
dbus_free (s);