Argument array of strings

Havoc Pennington hp at redhat.com
Sat Oct 21 09:24:10 PDT 2006


I've been going over and tuning up the API docs, and I discovered that 
get_array_len is in fact documented as returning the number of elements 
in the array. Also, why the hell would someone want the number of bytes 
in the wire protocol!

This is _not_ on purpose just a screwup. I think we should put #ifndef 
DBUS_DISABLE_DEPRECATED around this function and introduce 
dbus_message_iter_get_n_elements() that does something useful.

Shows that even simple functions can use test coverage...

Havoc

Thiago Macieira wrote:
> Peter Clifton wrote:
>> However, you will see from the output below, that it returns "54", not
>> "2". Is it returning the byte count of the array? I make that about 45,
>> including null terminators. Am I doing something stupid here?
> 
> It is the array length in bytes. Aside from the strings' contents and 
> their null terminators, you forgot to take into account:
> - each string's length indicator (4 bytes)
> - the padding required between each string to align at 8 bytes
> 
> You can't get the number of elements in an array like that. You have to 
> iterate over it. 
> 
> Hint: use glib. Don't venture yourself with the raw library.
> 
> 
> 
> ------------------------------------------------------------------------
> 
> _______________________________________________
> dbus mailing list
> dbus at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/dbus


More information about the dbus mailing list