diff options
author | Rob Taylor <rob.taylor@codethink.co.uk> | 2007-02-09 02:21:20 +0000 |
---|---|---|
committer | Rob Taylor <rob.taylor@codethink.co.uk> | 2007-02-09 02:21:20 +0000 |
commit | 133bc8003657169f622d4340360a0e5b15a455de (patch) | |
tree | 6c408893198e07b3214616678aee5d6ed4cca79e | |
parent | 5f70d7b59445b634f94469a8c12cf31f8f81fdae (diff) |
Allow passing of NULL to strv out arguments.
A nicety for the user, allows passing NULL to strv out arguments as shorthand for an empty array.
Patch due to Luiz Augusto von Dentz <luiz.dentz@gmail.com>
Fixes bug #8795.
-rw-r--r-- | dbus/dbus-gvalue.c | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/dbus/dbus-gvalue.c b/dbus/dbus-gvalue.c index cb1832c..a580725 100644 --- a/dbus/dbus-gvalue.c +++ b/dbus/dbus-gvalue.c @@ -1337,12 +1337,15 @@ marshal_strv (DBusMessageIter *iter, &subiter)) goto out; - for (elt = array; *elt; elt++) + if (array) { - if (!dbus_message_iter_append_basic (&subiter, + for (elt = array; *elt; elt++) + { + if (!dbus_message_iter_append_basic (&subiter, DBUS_TYPE_STRING, elt)) - goto out; + goto out; + } } if (!dbus_message_iter_close_container (iter, &subiter)) @@ -1370,10 +1373,13 @@ marshal_valuearray (DBusMessageIter *iter, &subiter)) goto oom; - for (i = 0; i < array->n_values; i++) + if (array) { - if (!_dbus_gvalue_marshal (&subiter, g_value_array_get_nth (array, i))) - return FALSE; + for (i = 0; i < array->n_values; i++) + { + if (!_dbus_gvalue_marshal (&subiter, g_value_array_get_nth (array, i))) + return FALSE; + } } if (!dbus_message_iter_close_container (iter, &subiter)) @@ -1770,7 +1776,7 @@ marshal_collection_array (DBusMessageIter *iter, * is this always true? If it is we can probably avoid * a lot of the overhead in _marshal_basic_instance... */ - if (!dbus_message_iter_append_fixed_array (&subiter, + if (!array || !dbus_message_iter_append_fixed_array (&subiter, subsignature_str[0], &(array->data), array->len)) |