From 257a4c5ac940fe14bb85518a78fc9dba1c78b959 Mon Sep 17 00:00:00 2001 From: Siddharth Date: Wed, 22 May 2019 02:42:19 +0200 Subject: Add BinaryenModuleWriteSExpr to write a module to a string in s-expr format (#2106) Fixes #2103. --- test/example/c-api-kitchen-sink.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'test/example/c-api-kitchen-sink.c') 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); } -- cgit v1.2.3