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; }