dbus/bus config-parser.c,1.43,1.44
John Palmieri
johnp at kemper.freedesktop.org
Fri Oct 27 11:30:24 PDT 2006
Update of /cvs/dbus/dbus/bus
In directory kemper:/tmp/cvs-serv31399/bus
Modified Files:
config-parser.c
Log Message:
* 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
Index: config-parser.c
===================================================================
RCS file: /cvs/dbus/dbus/bus/config-parser.c,v
retrieving revision 1.43
retrieving revision 1.44
diff -u -d -r1.43 -r1.44
--- config-parser.c 8 Aug 2006 23:29:03 -0000 1.43
+++ config-parser.c 27 Oct 2006 18:30:22 -0000 1.44
@@ -287,6 +287,52 @@
}
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 @@
_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 @@
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);
More information about the dbus-commit
mailing list