dbus/dbus dbus-message.c,1.159,1.160
Havoc Pennington
hp at freedesktop.org
Sun Jan 30 15:29:52 PST 2005
- Previous message: dbus/tools Makefile.am, 1.9, 1.10 dbus-names-model.c, NONE,
1.1 dbus-names-model.h, NONE, 1.1 dbus-tree-view.c, 1.5,
1.6 dbus-viewer.c, 1.6, 1.7
- Next message: dbus ChangeLog,1.674,1.675
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Update of /cvs/dbus/dbus/dbus
In directory gabe:/tmp/cvs-serv18563/dbus
Modified Files:
dbus-message.c
Log Message:
2005-01-30 Havoc Pennington <hp at redhat.com>
* tools/dbus-names-model.c (have_names_notify): fix this
* dbus/dbus-message.c (_dbus_message_iter_get_args_valist): clean
up the string array handling a bit
Index: dbus-message.c
===================================================================
RCS file: /cvs/dbus/dbus/dbus/dbus-message.c,v
retrieving revision 1.159
retrieving revision 1.160
diff -u -d -r1.159 -r1.160
--- dbus-message.c 30 Jan 2005 07:44:08 -0000 1.159
+++ dbus-message.c 30 Jan 2005 23:29:50 -0000 1.160
@@ -1765,7 +1765,7 @@
spec_element_type == DBUS_TYPE_OBJECT_PATH)
{
char ***str_array_p;
- int i;
+ int n_elements;
char **str_array;
str_array_p = va_arg (var_args, char***);
@@ -1777,14 +1777,14 @@
/* Count elements in the array */
_dbus_type_reader_recurse (&real->u.reader, &array);
- i = 0;
- if (_dbus_type_reader_has_next (&array))
+ n_elements = 0;
+ while (_dbus_type_reader_get_current_type (&array) != DBUS_TYPE_INVALID)
{
- while (_dbus_type_reader_next (&array))
- ++i;
+ ++n_elements;
+ _dbus_type_reader_next (&array);
}
- str_array = dbus_new0 (char*, i + 1);
+ str_array = dbus_new0 (char*, n_elements + 1);
if (str_array == NULL)
{
_DBUS_SET_OOM (error);
@@ -1795,29 +1795,32 @@
_dbus_type_reader_recurse (&real->u.reader, &array);
i = 0;
- if (_dbus_type_reader_has_next (&array))
+ while (i < n_elements)
{
- do
+ const char *s;
+ _dbus_type_reader_read_basic (&array,
+ &s);
+
+ str_array[i] = _dbus_strdup (s);
+ if (str_array[i] == NULL)
{
- const char *s;
- _dbus_type_reader_read_basic (&array,
- &s);
-
- str_array[i] = _dbus_strdup (s);
- if (str_array[i] == NULL)
- {
- dbus_free_string_array (str_array);
- _DBUS_SET_OOM (error);
- goto out;
- }
-
- ++i;
+ dbus_free_string_array (str_array);
+ _DBUS_SET_OOM (error);
+ goto out;
}
- while (_dbus_type_reader_next (&array));
+
+ ++i;
+
+ if (!_dbus_type_reader_next (&array))
+ _dbus_assert (i == n_elements);
}
+ _dbus_assert (_dbus_type_reader_get_current_type (&array) == DBUS_TYPE_INVALID);
+ _dbus_assert (i == n_elements);
+ _dbus_assert (str_array[i] == NULL);
+
*str_array_p = str_array;
- *n_elements_p = i;
+ *n_elements_p = n_elements;
}
#ifndef DBUS_DISABLE_CHECKS
else
- Previous message: dbus/tools Makefile.am, 1.9, 1.10 dbus-names-model.c, NONE,
1.1 dbus-names-model.h, NONE, 1.1 dbus-tree-view.c, 1.5,
1.6 dbus-viewer.c, 1.6, 1.7
- Next message: dbus ChangeLog,1.674,1.675
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the dbus-commit
mailing list