From a1cefa690d182d40c6503ef567bca0b02dcc5656 Mon Sep 17 00:00:00 2001 From: falsycat Date: Mon, 12 Feb 2024 23:18:38 +0900 Subject: [PATCH] fix an issue in example program --- example.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/example.c b/example.c index 4b75d52..b29934f 100644 --- a/example.c +++ b/example.c @@ -13,6 +13,7 @@ static inline bool acg_flush(struct acg_stream* s) { if (s->cursor_bits < 8U) { return false; } + FILE** fp = (void*) &s->udata; if (NULL == *fp) { *fp = fopen("log.acg", "wb"); @@ -23,6 +24,9 @@ static inline bool acg_flush(struct acg_stream* s) { if (1U != fwrite(s->buffer, s->cursor_bits/8U, 1U, *fp)) { return false; } + memset(s->buffer, 0U, (s->cursor_bits+7U)/8U); + s->cursor_bits = 0; + if (0U != fflush(*fp)) { return false; }