Empty Arrays

Kevin Krammer kevin.krammer at gmx.at
Sun Jan 28 16:52:22 PST 2007

On Monday 29 January 2007 01:41, Thiago Macieira wrote:
> Kevin Krammer wrote:
> >Today I found a problem when retrieving a zero length string array.
> >
> >The dbus_message_iter_recurse() call does not indicate whether the entry
> >iterator points to a valid position and I haven't found a function which
> >would tell me (might have missed it though).
> >
> >Right now I recurse and then detect that dbus_message_iter_get_arg_type
> > is 0, i.e. directly checking this literal. In case this is the way to
> > do this, is there a an official define/typedef to check against?
> That is the correct way to detect it.

Ok, thanks.
I'll check for DBUS_TYPE_INVALID then

> the dbus_message_iter_has_next function is broken: it tells you if there's
> at least 2 items in the array, so it can't be used as loop conditionals.
> Generally, you can loop like this:
>   dbus_message_iter_recurse(&array_it, &element_it);
>   dbus_message_iter_next(&array_it);

I think this skips the first item

>   while (dbus_message_iter_get_arg_type(&element_It) == DBUS_TYPE_INVALID)

you mean != right? ;)


Kevin Krammer, KDE developer, xdg-utils developer
KDE user support, developer mentoring

More information about the dbus mailing list