+int sd_bus_message_append_string_space(sd_bus_message *m, size_t size, char **s) {
+ struct bus_container *c;
+ char *e;
+ void *a;
+ int r;
+
+ if (!m)
+ return -EINVAL;
+ if (!s)
+ return -EINVAL;
+ if (m->sealed)
+ return -EPERM;
+
+ c = message_get_container(m);
+
+ if (c->signature && c->signature[c->index]) {
+ /* Container signature is already set */
+
+ if (c->signature[c->index] != SD_BUS_TYPE_STRING)
+ return -ENXIO;
+ } else {
+ /* Maybe we can append to the signature? But only if this is the top-level container*/
+ if (c->enclosing != 0)
+ return -ENXIO;
+
+ e = strextend(&c->signature, CHAR_TO_STR(SD_BUS_TYPE_STRING), NULL);
+ if (!e)
+ return -ENOMEM;
+ }
+
+
+ a = message_extend_body(m, 4, 4 + size + 1);
+ if (!a) {
+ r = -ENOMEM;
+ goto fail;
+ }
+
+ *(uint32_t*) a = size;
+ *s = (char*) a + 4;
+
+ (*s)[size] = 0;
+
+ if (c->enclosing != SD_BUS_TYPE_ARRAY)
+ c->index++;
+
+ return 0;
+
+fail:
+ if (e)
+ c->signature[c->index] = 0;
+
+ return r;
+}
+