diff options
author | David Robillard <d@drobilla.net> | 2018-06-15 09:26:17 -0400 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2023-12-02 16:27:02 -0500 |
commit | b631e7a3d6a807aaf4919396b62ba96e1a9f0bd9 (patch) | |
tree | 70a49bcc4d79d83d0f80f115da457514e09977d0 /src/byte_sink.h | |
parent | fe0b6d5d4d78cb31e1bf2381198890d070e46ed1 (diff) | |
download | serd-b631e7a3d6a807aaf4919396b62ba96e1a9f0bd9.tar.gz serd-b631e7a3d6a807aaf4919396b62ba96e1a9f0bd9.tar.bz2 serd-b631e7a3d6a807aaf4919396b62ba96e1a9f0bd9.zip |
Bring read/write interface closer to the C standard
Diffstat (limited to 'src/byte_sink.h')
-rw-r--r-- | src/byte_sink.h | 18 |
1 files changed, 9 insertions, 9 deletions
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 <string.h> 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; } } |