dbus/dbus dbus-object-tree.c,1.4,1.5
Olivier Andrieu
oandrieu at pdx.freedesktop.org
Fri May 21 02:05:22 PDT 2004
Update of /cvs/dbus/dbus/dbus
In directory pdx:/tmp/cvs-serv24501/dbus
Modified Files:
dbus-object-tree.c
Log Message:
2004-05-21 Olivier Andrieu <oliv__a at users.sourceforge.net>
* dbus/dbus-object-tree.c
(_dbus_object_tree_list_registered_unlock, lookup_subtree): return
children even if the requested path isn't registered.
(object_tree_test_iteration): test object_tree_list_registered.
* configure.in: undefine HAVE_ABSTRACT_SOCKETS instead of defining
it to 0.
Index: dbus-object-tree.c
===================================================================
RCS file: /cvs/dbus/dbus/dbus/dbus-object-tree.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- a/dbus-object-tree.c 2 Dec 2003 10:44:21 -0000 1.4
+++ b/dbus-object-tree.c 21 May 2004 09:05:20 -0000 1.5
@@ -344,6 +344,16 @@
}
static DBusObjectSubtree*
+lookup_subtree (DBusObjectTree *tree,
+ const char **path)
+{
+#if VERBOSE_FIND
+ _dbus_verbose ("Looking for subtree\n");
+#endif
+ return find_subtree_recurse (tree->root, path, FALSE, FALSE, NULL);
+}
+
+static DBusObjectSubtree*
find_handler (DBusObjectTree *tree,
const char **path)
{
@@ -553,12 +563,10 @@
*child_entries = NULL;
- subtree = find_subtree (tree, parent_path, NULL);
+ subtree = lookup_subtree (tree, parent_path);
if (subtree == NULL)
{
retval = dbus_new0 (char *, 1);
- if (retval == NULL)
- goto out;
}
else
{
@@ -1143,6 +1151,15 @@
return FALSE;
}
+static size_t
+string_array_length (char **array)
+{
+ size_t i;
+ for (i = 0; array[i]; i++) ;
+ return i;
+}
+
+
static dbus_bool_t
object_tree_test_iteration (void *data)
{
@@ -1287,6 +1304,46 @@
_dbus_assert (find_handler (tree, path7) != tree->root);
_dbus_assert (find_handler (tree, path8) != tree->root);
+ /* test the list_registered function */
+
+ {
+ const char *root[] = { NULL };
+ char **child_entries;
+ int nb;
+
+ _dbus_object_tree_list_registered_unlocked (tree, path1, &child_entries);
+ if (child_entries != NULL)
+ {
+ nb = string_array_length (child_entries);
+ _dbus_assert (nb == 1);
+ dbus_free_string_array (child_entries);
+ }
+
+ _dbus_object_tree_list_registered_unlocked (tree, path2, &child_entries);
+ if (child_entries != NULL)
+ {
+ nb = string_array_length (child_entries);
+ _dbus_assert (nb == 2);
+ dbus_free_string_array (child_entries);
+ }
+
+ _dbus_object_tree_list_registered_unlocked (tree, path8, &child_entries);
+ if (child_entries != NULL)
+ {
+ nb = string_array_length (child_entries);
+ _dbus_assert (nb == 0);
+ dbus_free_string_array (child_entries);
+ }
+
+ _dbus_object_tree_list_registered_unlocked (tree, root, &child_entries);
+ if (child_entries != NULL)
+ {
+ nb = string_array_length (child_entries);
+ _dbus_assert (nb == 3);
+ dbus_free_string_array (child_entries);
+ }
+ }
+
/* Check that destroying tree calls unregister funcs */
_dbus_object_tree_unref (tree);
More information about the dbus-commit
mailing list