]> git.ipfire.org Git - thirdparty/dbus.git/commitdiff
* bus/config-parser.c (service_dirs_find_dir,
authorJohn (J5) Palmieri <johnp@redhat.com>
Fri, 27 Oct 2006 18:30:22 +0000 (18:30 +0000)
committerJohn (J5) Palmieri <johnp@redhat.com>
Fri, 27 Oct 2006 18:30:22 +0000 (18:30 +0000)
  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

ChangeLog
bus/config-parser.c

index cae27411b2c2d4f4f06f4aefcba9e3facf18365a..b9b2ac657f2227416c276399e9e24bee72e78ea8 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2006-10-27  John (J5) Palmieri  <johnp@redhat.com>
+
+       * 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
+
 2006-10-27  Havoc Pennington  <hp@redhat.com>
 
        * dbus/dbus-sysdeps-pthread.c: make the "count" and "holder"
index 5b923632823d8cbbf6660f57d6ce1d417fbe345f..b126eb0c9b0e47d4bbb6172583c069e9e7f40c0a 100644 (file)
@@ -286,6 +286,52 @@ merge_service_context_hash (DBusHashTable *dest,
   return FALSE;
 }
 
+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,
@@ -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);