diff options
author | David Robillard <d@drobilla.net> | 2018-06-15 09:26:17 -0400 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2020-06-21 18:12:03 +0200 |
commit | 10bf7f7ce76d8b679449bfc9ba8b1814a79407fb (patch) | |
tree | ccb0aef1a21bdb603e4125e1b112d6ffd8b4ab53 /src/byte_sink.h | |
parent | 531b6c972df84a8f7545af2158236e9d0c3a460c (diff) | |
download | serd-10bf7f7ce76d8b679449bfc9ba8b1814a79407fb.tar.gz serd-10bf7f7ce76d8b679449bfc9ba8b1814a79407fb.tar.bz2 serd-10bf7f7ce76d8b679449bfc9ba8b1814a79407fb.zip |
Bring read/write interface closer to 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 62f233a0..7f891e7d 100644 --- a/src/byte_sink.h +++ b/src/byte_sink.h @@ -25,15 +25,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; @@ -50,7 +50,7 @@ static inline void serd_byte_sink_flush(SerdByteSink* bsink) { if (bsink->block_size > 1 && bsink->size > 0) { - bsink->sink(bsink->buf, bsink->size, bsink->stream); + bsink->sink(bsink->buf, 1, bsink->size, bsink->stream); bsink->size = 0; } } @@ -69,7 +69,7 @@ serd_byte_sink_write(const void* buf, size_t len, SerdByteSink* bsink) if (len == 0) { return 0; } else 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; @@ -85,7 +85,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; } } |