Re: Marshalling of empty string, object_path, signatures and NUL byte
Simon McVittie <simon.mcvittie-ZGY8ohtN/[email protected]>
| Newsgroups | gmane.comp.freedesktop.dbus |
|---|---|
| Organization | Collabora Ltd. |
| Message-ID | <[email protected]> |
On 25/05/16 09:06, [email protected] wrote: > what is the correct approach to marshall empty strings, object paths and > sinatures? (with length == 0)? > > Should it contain just NUL byte after length of just length alone? I'm fairly sure empty strings aren't special. Non-empty strings are marshalled as a length, followed by some data, followed by a NUL; empty strings are marshalled as a length, followed by no data, followed by a NUL. (Strings are encoded this way so that a C implementation like libdbus can point directly into the message buffer and get a NUL-terminated const char * that it can provide to the library user, without having to memcpy it out.) If in doubt, look at what the D-Bus Specification says, or at what a high-quality interoperable implementation (for instance libdbus, GDBus, sd-bus) emits. -- Simon McVittie Collabora Ltd. <http://www.collabora.com/> _______________________________________________ dbus mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dbus