From fa820c60a8d1699dbe0f0644e7e1efdaf4d5a1ee Mon Sep 17 00:00:00 2001 From: "Edward A. Lee" Date: Sat, 9 Mar 2024 17:53:51 -0800 Subject: [PATCH] Fix compile problems appearing with the updated release --- examples/C/src/ReflexGame/ReflexGame.lf | 4 ---- examples/C/src/distributed/HelloWorld.lf | 8 ++++++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/examples/C/src/ReflexGame/ReflexGame.lf b/examples/C/src/ReflexGame/ReflexGame.lf index 78ef6c3d..e776b5ff 100644 --- a/examples/C/src/ReflexGame/ReflexGame.lf +++ b/examples/C/src/ReflexGame/ReflexGame.lf @@ -13,10 +13,6 @@ target C { keepalive: true } -preamble {= - #include "include/core/platform.h" -=} - /** * Produce a counting sequence at random times with a minimum and maximum time between outputs * specified as parameters. diff --git a/examples/C/src/distributed/HelloWorld.lf b/examples/C/src/distributed/HelloWorld.lf index a409748d..b3884ccd 100644 --- a/examples/C/src/distributed/HelloWorld.lf +++ b/examples/C/src/distributed/HelloWorld.lf @@ -38,10 +38,14 @@ reactor MessageGenerator(prefix: string = "") { // With NULL, 0 arguments, snprintf tells us how many bytes are needed. // Add one for the null terminator. int length = snprintf(NULL, 0, "%s %d", self->prefix, self->count) + 1; + // Dynamically allocate memory for the output. - SET_NEW_ARRAY(message, length); + char* buffer = malloc(length); + // Populate the output string and increment the count. - snprintf(message->value, length, "%s %d", self->prefix, self->count++); + snprintf(buffer, length, "%s %d", self->prefix, self->count++); + + lf_set_array(message, buffer, length); tag_t tag = lf_tag(); lf_print("At (elapsed) logical tag (%lld, %u), source sends message: %s",