summaryrefslogtreecommitdiff
path: root/test/example/c-api-kitchen-sink.c
diff options
context:
space:
mode:
Diffstat (limited to 'test/example/c-api-kitchen-sink.c')
-rw-r--r--test/example/c-api-kitchen-sink.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/test/example/c-api-kitchen-sink.c b/test/example/c-api-kitchen-sink.c
index 0efafde52..43069c865 100644
--- a/test/example/c-api-kitchen-sink.c
+++ b/test/example/c-api-kitchen-sink.c
@@ -785,6 +785,19 @@ void test_binaries() {
assert(BinaryenModuleValidate(module));
printf("module loaded from binary form:\n");
BinaryenModulePrint(module);
+
+ // write the s-expr representation of the module.
+ BinaryenModuleWriteText(module, buffer, 1024);
+ printf("module s-expr printed (in memory):\n%s\n", buffer);
+
+
+ // writ the s-expr representation to a pointer which is managed by the
+ // caller
+ char *text = BinaryenModuleAllocateAndWriteText(module);
+ printf("module s-expr printed (in memory, caller-owned):\n%s\n", text);
+ free(text);
+
+
BinaryenModuleDispose(module);
}