diff options
Diffstat (limited to 'src/byte_sink.h')
-rw-r--r-- | src/byte_sink.h | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/src/byte_sink.h b/src/byte_sink.h index ed0f65b4..65b5eb12 100644 --- a/src/byte_sink.h +++ b/src/byte_sink.h @@ -33,13 +33,18 @@ serd_byte_sink_new(SerdSink sink, void* stream, size_t block_size) return bsink; } -static inline void +static inline SerdStatus serd_byte_sink_flush(SerdByteSink* bsink) { if (bsink->block_size > 1 && bsink->size > 0) { - bsink->sink(bsink->buf, bsink->size, bsink->stream); - bsink->size = 0; + const size_t size = bsink->size; + const size_t n_out = bsink->sink(bsink->buf, size, bsink->stream); + bsink->size = 0; + + return (n_out != size) ? SERD_ERR_BAD_WRITE : SERD_SUCCESS; } + + return SERD_SUCCESS; } static inline void |