From b631e7a3d6a807aaf4919396b62ba96e1a9f0bd9 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Fri, 15 Jun 2018 09:26:17 -0400 Subject: Bring read/write interface closer to the C standard --- src/byte_sink.h | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'src/byte_sink.h') diff --git a/src/byte_sink.h b/src/byte_sink.h index 0f3d35f5..d033f227 100644 --- a/src/byte_sink.h +++ b/src/byte_sink.h @@ -13,15 +13,15 @@ #include typedef struct SerdByteSinkImpl { - SerdSink sink; - void* stream; - char* buf; - size_t size; - size_t block_size; + SerdWriteFunc sink; + void* stream; + char* buf; + size_t size; + size_t block_size; } SerdByteSink; static inline SerdByteSink -serd_byte_sink_new(SerdSink sink, void* stream, size_t block_size) +serd_byte_sink_new(SerdWriteFunc sink, void* stream, size_t block_size) { SerdByteSink bsink; bsink.sink = sink; @@ -38,7 +38,7 @@ serd_byte_sink_flush(SerdByteSink* bsink) { if (bsink->block_size > 1 && bsink->size > 0) { const size_t size = bsink->size; - const size_t n_out = bsink->sink(bsink->buf, size, bsink->stream); + const size_t n_out = bsink->sink(bsink->buf, 1, bsink->size, bsink->stream); bsink->size = 0; return (n_out != size) ? SERD_BAD_WRITE : SERD_SUCCESS; @@ -63,7 +63,7 @@ serd_byte_sink_write(const void* buf, size_t len, SerdByteSink* bsink) } if (bsink->block_size == 1) { - return bsink->sink(buf, len, bsink->stream); + return bsink->sink(buf, 1, len, bsink->stream); } const size_t orig_len = len; @@ -79,7 +79,7 @@ serd_byte_sink_write(const void* buf, size_t len, SerdByteSink* bsink) // Flush page if buffer is full if (bsink->size == bsink->block_size) { - bsink->sink(bsink->buf, bsink->block_size, bsink->stream); + bsink->sink(bsink->buf, 1, bsink->block_size, bsink->stream); bsink->size = 0; } } -- cgit v1.2.1