diff options
author | Ralf Habacker <ralf.habacker@freenet.de> | 2015-11-27 12:10:54 +0100 |
---|---|---|
committer | Ralf Habacker <ralf.habacker@freenet.de> | 2016-02-11 02:41:12 +0100 |
commit | 1370b44035da90a7fbcebea17074c66c832de0b1 (patch) | |
tree | 689a3f27d31e45e1b0aef005c312ef1e27551230 | |
parent | d893121efdea39d2b32037b32e336ea483829b2e (diff) | |
download | dbus-1370b44035da90a7fbcebea17074c66c832de0b1.tar.gz |
Rename function string_array_length() to _dbus_string_array_length() and move it to dbus-internals.c.
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=92899
Reviewed-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
-rw-r--r-- | dbus/dbus-internals.c | 15 | ||||
-rw-r--r-- | dbus/dbus-internals.h | 2 | ||||
-rw-r--r-- | dbus/dbus-object-tree.c | 22 |
3 files changed, 24 insertions, 15 deletions
diff --git a/dbus/dbus-internals.c b/dbus/dbus-internals.c index 30a5fa73..d4f0433d 100644 --- a/dbus/dbus-internals.c +++ b/dbus/dbus-internals.c @@ -642,6 +642,21 @@ _dbus_string_array_contains (const char **array, } /** + * Returns the size of a string array + * + * @param array array to search. + * @returns size of array + */ +size_t +_dbus_string_array_length (const char **array) +{ + size_t i; + for (i = 0; array[i]; i++) {} + return i; +} + + +/** * Generates a new UUID. If you change how this is done, * there's some text about it in the spec that should also change. * diff --git a/dbus/dbus-internals.h b/dbus/dbus-internals.h index 3eb8749f..6f92fa4c 100644 --- a/dbus/dbus-internals.h +++ b/dbus/dbus-internals.h @@ -246,6 +246,8 @@ void* _dbus_memdup (const void *mem, DBUS_PRIVATE_EXPORT dbus_bool_t _dbus_string_array_contains (const char **array, const char *str); +DBUS_PRIVATE_EXPORT +size_t _dbus_string_array_length (const char **array); char** _dbus_dup_string_array (const char **array); #define _DBUS_INT16_MIN ((dbus_int16_t) 0x8000) diff --git a/dbus/dbus-object-tree.c b/dbus/dbus-object-tree.c index e2a3b737..27481a81 100644 --- a/dbus/dbus-object-tree.c +++ b/dbus/dbus-object-tree.c @@ -1592,14 +1592,6 @@ do_test_dispatch (DBusObjectTree *tree, return FALSE; } -static size_t -string_array_length (const char **array) -{ - size_t i; - for (i = 0; array[i]; i++) ; - return i; -} - typedef struct { const char *path; @@ -1634,14 +1626,14 @@ run_decompose_tests (void) &result, &result_len)) return FALSE; - expected_len = string_array_length (decompose_tests[i].result); + expected_len = _dbus_string_array_length (decompose_tests[i].result); - if (result_len != (int) string_array_length ((const char**)result) || + if (result_len != (int) _dbus_string_array_length ((const char**)result) || expected_len != result_len || path_contains (decompose_tests[i].result, (const char**) result) != STR_EQUAL) { - int real_len = string_array_length ((const char**)result); + int real_len = _dbus_string_array_length ((const char**)result); _dbus_warn ("Expected decompose of %s to have len %d, returned %d, appears to have %d\n", decompose_tests[i].path, expected_len, result_len, real_len); @@ -1875,7 +1867,7 @@ object_tree_test_iteration (void *data) _dbus_object_tree_list_registered_unlocked (tree, path1, &child_entries); if (child_entries != NULL) { - nb = string_array_length ((const char**)child_entries); + nb = _dbus_string_array_length ((const char**)child_entries); _dbus_assert (nb == 1); dbus_free_string_array (child_entries); } @@ -1883,7 +1875,7 @@ object_tree_test_iteration (void *data) _dbus_object_tree_list_registered_unlocked (tree, path2, &child_entries); if (child_entries != NULL) { - nb = string_array_length ((const char**)child_entries); + nb = _dbus_string_array_length ((const char**)child_entries); _dbus_assert (nb == 2); dbus_free_string_array (child_entries); } @@ -1891,7 +1883,7 @@ object_tree_test_iteration (void *data) _dbus_object_tree_list_registered_unlocked (tree, path8, &child_entries); if (child_entries != NULL) { - nb = string_array_length ((const char**)child_entries); + nb = _dbus_string_array_length ((const char**)child_entries); _dbus_assert (nb == 0); dbus_free_string_array (child_entries); } @@ -1899,7 +1891,7 @@ object_tree_test_iteration (void *data) _dbus_object_tree_list_registered_unlocked (tree, root, &child_entries); if (child_entries != NULL) { - nb = string_array_length ((const char**)child_entries); + nb = _dbus_string_array_length ((const char**)child_entries); _dbus_assert (nb == 3); dbus_free_string_array (child_entries); } |