summaryrefslogtreecommitdiff
path: root/src/libsystemd-bus/test-bus-marshal.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2013-05-10 01:12:15 +0200
committerLennart Poettering <lennart@poettering.net>2013-05-10 03:38:11 +0200
commitf8e013f8bf476e6d61fb2e218c85e23032a46302 (patch)
tree184319e3255790107b879247ebd6d1ca925190c8 /src/libsystemd-bus/test-bus-marshal.c
parent2e996f4d4b642c5682c608c9692ad2ffae398ab2 (diff)
bus: add sd_bus_message_append_string_space() for zero-copy string appending
Diffstat (limited to 'src/libsystemd-bus/test-bus-marshal.c')
-rw-r--r--src/libsystemd-bus/test-bus-marshal.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/libsystemd-bus/test-bus-marshal.c b/src/libsystemd-bus/test-bus-marshal.c
index ac519531f7..ef1a77f5fc 100644
--- a/src/libsystemd-bus/test-bus-marshal.c
+++ b/src/libsystemd-bus/test-bus-marshal.c
@@ -44,6 +44,7 @@ int main(int argc, char *argv[]) {
size_t sz;
char *h;
const int32_t integer_array[] = { -1, -2, 0, 1, 2 }, *return_array;
+ char *s;
r = sd_bus_message_new_method_call(NULL, "foobar.waldo", "/", "foobar.waldo", "Piep", &m);
assert_se(r >= 0);
@@ -78,6 +79,10 @@ int main(int argc, char *argv[]) {
r = sd_bus_message_close_container(m);
assert_se(r >= 0);
+ r = sd_bus_message_append_string_space(m, 5, &s);
+ assert_se(r >= 0);
+ strcpy(s, "hallo");
+
r = sd_bus_message_append_array(m, 'i', integer_array, sizeof(integer_array));
assert_se(r >= 0);
@@ -172,6 +177,10 @@ int main(int argc, char *argv[]) {
assert_se(streq(x, "foobar"));
assert_se(streq(y, "waldo"));
+ r = sd_bus_message_read_basic(m, 's', &s);
+ assert_se(r > 0);
+ assert_se(streq(s, "hallo"));
+
r = sd_bus_message_read_array(m, 'i', (const void**) &return_array, &sz);
assert_se(r > 0);
assert_se(sz == sizeof(integer_array));