From 4ada4d49963952bcc3b6f896af4c9a91525877ea Mon Sep 17 00:00:00 2001 From: Folkert Date: Wed, 28 Sep 2022 15:30:17 +0200 Subject: [PATCH] deallocate roc string in parser platform --- examples/parser/platform/host.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/examples/parser/platform/host.c b/examples/parser/platform/host.c index 088109178d..56465121be 100644 --- a/examples/parser/platform/host.c +++ b/examples/parser/platform/host.c @@ -143,9 +143,22 @@ int main() { size_t written = fwrite(str_bytes, sizeof(char), str_len, stdout); if (fflush(stdout) == 0 && written == str_len) { // Writing succeeded! + + // dealllocate the roc string + if (!(is_small_str(str))) { + roc_dealloc(str_bytes - 8, 1); + } + return 0; } else { printf("Error writing to stdout: %s\n", strerror(errno)); + + // dealllocate the roc string + if (!(is_small_str(str))) { + roc_dealloc(str_bytes - 8, 1); + } + return 1; } + }